RE: "a reference to"
RE: "a reference to"
- Subject: RE: "a reference to"
- From: Scott Babcock <email@hidden>
- Date: Thu, 24 Jan 2008 14:00:58 -0800
- Acceptlanguage: en-US
- Thread-topic: "a reference to"
Is "contents" a property or an operator? The ASLG is inconclusive.
In addition to the [contents] property, the description of the 'reference' class indicates that a reference has a [class] property whose value is always 'reference'. This is clearly wrong. Ask a reference for its class and you'll get the class of the object to which it refers instead.
Also, check "NOTES" under "Repeat With (loopVariable) In (list)":
"... you must use the 'contents of' operator:"
> You can't [dereference] something that isn't a reference.
This is precisely my point. recordRef is clearly a reference, because changes applied to it affect the corresponding list item from which it derives. It's clearly not a 'reference' object, since it can't be coerced to 'reference'. However, the 'contents of' operator creates a shallow copy of the original record, a textbook example of dereferencing.
Digging into the details of how complex items are stored in lists has been instructive for me. I don't think this is a quirk to be avoided. Although it's potentially confusing, I think this is useful behavior. With knowledge comes understanding, and complex data manipulation becomes easier. The failure of 'reference' coercion for these types of references may be a bug, but probably not worth fixing.
-----Original Message-----
Date: Thu, 24 Jan 2008 19:24:50 +0000
From: has <email@hidden>
Subject: Re: "a reference to"
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On 24 Jan 2008, at 18:34, Scott Babcock wrote:
> Yes, recordRef is bound to the {foo:"foo"} record, but it's not an
> AppleScript 'reference' object.
Didn't say it was.
> Only a 'reference' can be coerced to 'reference', and an error is
> thrown if you try this on recordRef.
Yep.
> Even so, the 'contents of' operator de-references recordRef into a
> local copy:
You can't deference something that isn't a reference. 'contents of' (which is a property reference, not an operator) makes a shallow copy of the object bound to recordRef. Given that the ASLG doesn't list a 'contents' property for either list or record types I'm inclined to think it's an undocumented behaviour, although you'd need to check the rest of the ASLG to be sure. As with other avoidable AppleScript quirks, the best advice is "don't do that".
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden