Re: handler failure
Re: handler failure
- Subject: Re: handler failure
- From: Paul Skinner <email@hidden>
- Date: Fri, 15 Nov 2002 10:15:28 -0500
On Thursday, November 14, 2002, at 03:14 PM, Michael Sullivan wrote:
On Wednesday Paul Skinner wrote:
I certainly don't think that it should be expected that a handler
plucked from it's environment should 'remember' how things used to be
'back on the farm script' so to speak.
Oh, but I do. It's called lexical scoping, and IIRC, applescript
claims to have it.
I don't know anything about that. I can't find anything about it
anywhere on Apple.com or Google.
Literally it means that the scope of variables is defined by the block
where they are introduced in the text of the source code, *not* the
block they happen to be in when called.
I did find this at The Free Online Dictionary of Computing
(
http://foldoc.doc.ic.ac.uk/)
lexical scope
<programming> (Or "static scope") In a lexically scoped language, the
scope of an identifier is fixed at compile-time to be the smallest
block (begin/end or function/procedure body) containing the
identifier's declaration. This means that an identifier declared in
some block is only accessible within that block and from procedures
declared within it.
Opposite of dynamic scope. See activation record.
(1995-05-09)
If AppleScript is lexically scoped then it according to this it does
sound like the property should be available to the handler declared
within the original script. I can only say that I always thought that
when you assign a handler to a variable that you were creating a new
instance of the handler. This was because I've never gotten a reference
back from such an assignment. If that was the case I would expect to
get '<<handler handlerName>> of <<script scriptName>>' or some such
thing. But I never have.
If set copies a reference (as it claims to for anything as complex as
a handler), then the scoping should work properly. b's bar, becomes a
reference that points to "a's foo" which is lexically part of script
a, and so should have script a as it's scope.
Maybe, but it doesn't appear to do that.
on s1()
say "handler s1"
end s1
on s2()
say "handler s2"
end s2
set x to s1
set s1 to s2
{x, s1, s2}
--> {<<handler s1>>, <<handler s2>>, <<handler s2>>}
--You can make a reference to a handler, but you can't call that
reference.
set b to a reference to s1--> s1 of <<script>>
b()--> <<script>> doesn't understand the c message.
--It does make a proper reference though.
set b to a reference to s1--> s1 of <<script>>
set c to b
set s1 to pi
{s1, b as text, c as text}
--> {3.14159265359, 3.14159265359, 3.14159265359}
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.