Re: Variable Ponderance
Re: Variable Ponderance
- Subject: Re: Variable Ponderance
- From: has <email@hidden>
- Date: Thu, 30 Sep 2004 21:34:06 +0100
Ben Waldie wrote:
I think I have noticed this before, but just never questioned it.
In the following examples, I set a local variable to a value, and then
pass that variable down to a handler as a parameter.
set x to {1, 2, 3}
doSomething(x)
You're not passing a variable (x). You're passing the object that's
stored in it.
on doSomething(y)
set item 1 of y to 2
end doSomething
And here you're not modifying the variable (y), you're modifying the
content of the object that's stored in it. Which is the _same object_
as is stored in variable x.
Ech, this one bites everybody sooner or later. (Not helped by the
ASLG's lame attempt to explain it - some vague rubbish about "data
sharing" buried somewhere in the middle). Short answer: follow the
objects, not the variables.
--
Footnote: There's really only two key concepts you need to get to
understanding how AppleScript works: objects and messages. I'd
suggest googling for an introduction to the basic principles of the
Smalltalk language, which is all about creating objects and sending
messages between them. AppleScript nicks most of its good ideas from
Smalltalk, so if you can understand how Smalltalk operates then
AppleScript will make much more sense to you.
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden