In Applescript, why do local variables in handlers capture "with" labeled parameters?
Posted
by outis
on Stack Overflow
See other posts from Stack Overflow
or by outis
Published on 2010-04-26T01:03:23Z
Indexed on
2010/04/26
1:13 UTC
Read the original article
Hit count: 303
applescript
In Applescript, if you declare a handler using "with" labeled parameters, local variables get the values of the arguments and the parameters themselves are undefined. For example:
on bam of thing with frst and scnd
local eat_frst
return {thing: thing, frst:frst, scnd:scnd} -- this line throws an error
end bam
bam of "bug-AWWK!" with frst without scnd
results in an error message that "scnd" isn't defined in the second line of bam
. thing
and frst
are both defined, getting the arguments passed in the call to bam
. Why is this happening? Why is scnd
undefined?
Note: I know that declaring variables as "local" within a handler is unnecessary. It's done in the examples for illustrative purposes.
© Stack Overflow or respective owner