Scott Norton is brilliant (was: solutions to scripting addition t erminology confilicts)
Scott Norton is brilliant (was: solutions to scripting addition t erminology confilicts)
- Subject: Scott Norton is brilliant (was: solutions to scripting addition t erminology confilicts)
- From: Olof Hellman <email@hidden>
- Date: Fri, 25 Jan 2002 13:47:14 -0800
Scott Norton writes:
>
> Solution 1: The introduction of a "using module" block and a
>
> "Scripting Modules" folder.
>
>
I think you might be able to do such a thing using an
>
ordinary "using terms from..." block, by defining a terminology-only
application.
>
(I've previously used a terminology-only Scripting Addition to blatenly
>
pollute the global namespace, so this approach will restore my karmic
balance.)
>
Now, I haven't tested any of this, but I think it ought to work.
>
>
To produce a 'module', which will have limited terminology scope but have
the
>
response speed of a Scripting Addition, break the Scripting Addition into
two
>
pieces. Piece 1 is the Scripting Addition less its terminology, and Piece
2 is
>
the terminology. (Call them osax-code and osax-terminology for now.)
Apologies if Scott isn't the first to have suggested this, but this is
simply a brilliant idea. To rephrase the logic if you didn't get it the
first time:
1) OSAXen install apple event handlers in the system dispatch table. The
identifiers for the event handlers are stored in the 'osax' (68k code) or
'osiz' (PPC code) resources. These handlers will get called whenever the
system sees an event of the appropriate event suite/ID
2) OSAXen define terminology in their 'aete' resources which bind
AppleScript terminology to the events handled by the OSAX
3) OSAXen pollute the global namespace if they have an 'aete' resource, and
this is very bad.
4) AppleScript already has a construct, namely, 'using terms from', to
define the scope of an 'aete' resource's terminology when compiling a
script.
5) Scott proposes to take the 'aete' out of the OSAX and put it in a
different file, lets call it an OSAX terminology file. The effect of this
is :
5a) OSAX terminology no longer pollutes the global namespace. There is no
'aete' attached to the OSAX, so AppleScript will not load it.
5b) The terminology can be used when compiling a script by specifying
something like:
using terms from file "system folder:osax-terminology:standard
additions"
5c) AppleScript will still load the AppleEvent handlers defined in the
'osax' or 'osiz' resources into the system dispatch table. Thus, the events
still get handled by the OSAX with all the inherent speed advantages.
I nominate Scott for 'best AppleScript idea of the year' award.
- Olof