Re: Creating list references in handlers. Bad code or bug?
Re: Creating list references in handlers. Bad code or bug?
- Subject: Re: Creating list references in handlers. Bad code or bug?
- From: Christopher Nebel <email@hidden>
- Date: Wed, 3 Oct 2001 15:47:15 -0700
On Wednesday, October 3, 2001, at 02:50 PM, Michael Sullivan wrote:
On Sunday, September 16, 2001, at 01:19 PM, Victor Yee wrote:
Hmmm, is this a bug?
set x to {1, 2}
set end of x's contents to 3
x
--> {1, 2}
It is, as we say, "working as designed." There are two problems here:
one is that object specifiers for AppleScript internal objects (like
lists) are fully evaluated at each sub-bit.
I'm not sure I get what this means. By sub-bit are you referring to a
parse unit?
Sorry, I should have been clearer there. What I meant was an individual
"x of y" expression. If you say "foo of bar of baz", AppleScript
evaluates "bar of baz", then evaluates "foo of the result".
Now that I think about it a bit more, that's irrelevant here; the key
point is that "contents" of a list is a computed property like
"reverse", so you can't affect the underlying list through it. If
"contents" just returned the exact same list, the snippet above would
have returned {1, 2, 3}.
--Chris Nebel
AppleScript Engineering