In Applescript, why do local variables in handlers capture "with" labeled parameters?
- by outis
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.