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: Helmut Fuchs <email@hidden>
- Date: Sat, 15 Sep 2001 15:29:38 +0200
At 8:04 Uhr -0400 15.09.2001, Victor Yee wrote:
Was thinking about this and I believe that there is an implicit
"get" involved here.
Never looked at this from that perspective... but even though it
looks like it works - it's not a reference you're having there.
If you run the following, you'll see what I mean:
on theHandler()
local theData, notRealListReference, realListReference, theData1
set theData to {theList:{"unchanged!"}}
set notRealListReference to a reference to (get theList of theData)
set item 1 of contents of notRealListReference to "changed!"
copy theData to theData1
set realListReference to a reference to theList of theData
set item 1 of contents of realListReference to "changed!"
return {theList of theData1, theList of theData}
end theHandler
theHandler()
This results in: {{"unchanged!"}, {"changed!"}}.
By using 'get' one ends up working with a _copy_ of the original data
(at least in the above case). Whereas without the 'get' you can make
use of data sharing.
If you need references to local variables, then you are limited to
references into objects that are subject to data sharing as described
in ASLG.
Helmut