Re: AS Library Question
Re: AS Library Question
- Subject: Re: AS Library Question
- From: has <email@hidden>
- Date: Tue, 15 Dec 2015 18:11:31 +0000
Shane Stanley wrote:
> On 15 Dec 2015, at 11:26 AM, has <email@hidden> wrote:
>>
>> you'll have to get rid of any sub-modules (which the AS loader
doesn't support)
>
> I'm not exactly sure what you mean here,
AM Loader allows libraries to contain their own libraries, allowing
large complex libraries to themselves be modularized for easier
maintenance and reuse. e.g. See the AM Types.scptd library, which has
several sub-libraries in its own Scripts folder. The section in
<http://applemods.sourceforge.net/using-loader.html> explains how Loader
searches various scopes (it'd have been clearer with a diagram, but eh
it was a rush job). Pretty much every language supports this, e.g. see
Python packages, Cocoa sub-frameworks, etc.
AS's library loader, from what I can tell, has no such concept of
hierarchical or private namespaces. As I've said, it's primitive and
limited and doesn't scale well in various ways (not that there is an AS
library ecosystem for it to scale to anyway). The only way you could do
"namespacing" in AS libraries is to put all your related scripts in the
same `Script Libraries` folder and add custom codes to their filenames
a-la ObjC classes, though that creates clutter and confusion for users,
and is just more opportunities for bits to get lost or broken.
Since none of the AM libraries are particularly large and complex, the
simplest thing to do is just to get rid of the sub-library files
altogether and paste their code into the main script. IIRC, when I redid
the AppleMods site to coincide with the Apress book[1], I threw out most
of the crappily implemented and less useful libraries anyway, so it's
probably very little work to convert what's left anyway. Yeah, I know
it'd be quickest just to do the job myself and that way it's all done,
OTOH, if the rest of the AS community cares enough then it won't take
them long to do, and may encourage them to take it further themselves.
Besides which, I'm already busy writing the library loader for my *next*
language. :)
has
[1] Having added a nice new section to the Apress book on how to work
with libraries, I actually needed some existing libraries to use as
examples, so I quickly rebooted the by-then-defunct AM project while the
book was going to press, redoing the Loader to try to make it nicer to
use (e.g. replacing the cruddy bootstrap applet with an osax) and
getting rid of the crappier libraries. Had the book led to an uptick in
interest I might've worked on AM further, but there wasn't so I just
left it at that[2].
[2] Conclusion: building a viable library ecosystem is one of those
problems that's hopeless trying to solve without ongoing support and
involvement from the core language team. Not because it's technically
hard but because it requires 1. a lot of logistical and education work
even just to get users aware that libraries exist and why they'd be
useful; and 2. a very low barrier to entry by having an easy-to-use
loader built into the language itself and a good set of general-purpose
libraries already included in the OS. So after a mere 23 years we're now
about 10% of the way there, which by AS standards is pretty good
progress. :p
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden