Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
- Subject: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
- From: Axel Luttgens <email@hidden>
- Date: Mon, 12 Apr 2004 15:45:42 +0200
Michael Terry wrote:
On Apr 11, 2004, at 8:17 AM, Nigel Garvey wrote:
Michael Terry wrote on Fri, 9 Apr 2004 18:15:26 -0700:
set x to 3
set y to 4
set a to a reference to x
set b to a reference to y
set contents of {a, b} to {"hello", "there"}
--> Can't set contents of {x, y} to {"hello", "there"}.
Even look at the error message there: I didn't ask to set the
*contents* of {x, y}, but AS does recognize that I wanted to set {x,
y}, not {3, 4}. I *asked* to set the contents of {a, b} to {"hello",
"there"}.
I'm not sure that requiring the contents property in the above led
AppleScript to recognize something subtle.
Consider this one:
set x to 3
set y to 4
set a to a reference to x
set b to a reference to y
set pi of {a, b} to {"hello", "there"}
--> Can't set pi of {x of <<script>>, y of <<script>>} to {"hello",
"there"}.
Exactly the same "clever" behavior.
In fact, one is asking AppleScript to evaluate an expression: take a
property ("contents" in your example, "pi" in mine) of something.
Here, that something is a list of two references, whose evaluation
consists of taking the contents of the references and return the
corresponding list.
contents of {a, b}
... should return a list of lvalues in this context, wouldn't you say?
No, because you just asked to evaluate an expression.
And the result of that evaluation is a list of two variables that, as
such, can't be set to something else (the same way you can't, say, set 1
to 2): that list is a terminal value.
Now, the amusing thing is that one may write:
set {x,y} to {"hello", "there"}
But this is a syntactic illusion, as it goes on pattern matching.
And to be able to use that pattern matching mechanism with your initial
example, you really need to write:
set x to 3
set y to 4
set a to a reference to x
set b to a reference to y
set {contents of a, contents of b} to {"hello", "there"}
Hmm... not sure I managed to be comprehensible.
Axel
_______________________________________________
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.