Michael Sullivan wrote:
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. The way I like to say this (I think it's equivalent) is that some objects (anything other than a number IIRC) are never stored in variables -- only a reference (pointer if you prefer, but reference is more general) is stored in the variable binding.
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.
set x to {1, 2, 3} doSomething(x)
on doSomething(y) set item 1 of y to 2 end doSomething
Cheers,
has