Re: Script Object Order in Script
Re: Script Object Order in Script
- Subject: Re: Script Object Order in Script
- From: Christopher Nebel <email@hidden>
- Date: Thu, 26 Jul 2001 00:22:31 -0700
On Wednesday, July 25, 2001, at 08:33 PM, email@hidden wrote:
I think Chris Nebel explained a while ago what was going on inside the
compiler.
When "whatever of aaa" is begin compiled, the symbol table has an
entry for
"aaa" as a top-level script object. So the reference to "aaa" in
"whatever of
aaa" is encoded as a reference to that object. But when "whatever of
zzz" is
seen, "zzz" isn't in the symbol table. So the compiler decides this is
a local
variable of the CheckScriptProperties function, and creates such an
entry in the
symbol table. That local variable then masks the top-level script
object zzz
when the script runs.
I don't recall ever explaining this, but that is the correct answer.
Because AppleScript doesn't require you to declare variables before
using them and has a single-pass compiler, it has to decide whether
something is a local or global based on what it's already seen. The
default for anything inside a handler is that it's a local, unless you
explicitly qualify it using "my" or "of something".
--Chris Nebel
AppleScript Engineering