Re: Dumb performance question: tell blocks
Re: Dumb performance question: tell blocks
- Subject: Re: Dumb performance question: tell blocks
- From: Christopher Nebel <email@hidden>
- Date: Tue, 17 Oct 2006 11:20:19 -0700
On Oct 17, 2006, at 7:11 AM, Mark J. Reed wrote:
On 10/17/06, Michelle Steiner <email@hidden> wrote:
I believe that if you put it inside a tell block, AS will first
send the command to the application; if the application doesn't
know what to do with it, it will go back to AS and then do the
built in.
That'd be the core of my question. Is it a runtime thing, where the
interpreter sends the events to the app first, or is it a compile-
time thing, where the compiler checks the app's dictionary first
and, not finding the commands, just compiles them as builtins?
That depends on what you mean by "built-in". This is more subtle than
you might imagine. The rule is: if it sends an event, it'll get sent
to the "tell" target, which either handles it or it doesn't. End of
story. [1] The easiest way to tell if a command sends an event or not
is to watch the event log -- does the operation show up there? As
rule of thumb, scripting additions do send events; operations on
native data types (such as counting the items in a list) do not.
This is all irrespective of any terminology-clashing issues, of
course, so as Michelle points out, it's still a good idea to limit
your "tell" scope for that reason. And don't forget: don't bother
trying to optimize something until you're dissatisfied with how fast
it runs. [2]
--Chris Nebel
AppleScript Engineering
[1] As with so many simple explanations, this glosses over a detail.
If AppleScript sends a command to an application and it says it
doesn't handle it, *and* it can find a matching event handler in its
own process, then it tells the remote application to load scripting
additions and then sends it the event again. The upshot is that the
event still gets processed in the remote application, but it takes two
tries to do it.
[2] See <http://en.wikipedia.org/wiki/Software_optimization#Quotes>.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden