Re: Record/List Coercion
Re: Record/List Coercion
- Subject: Re: Record/List Coercion
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 30 Apr 2008 07:13:08 -0400
I wrote:
> Records are not associative arrays.
Then Emmanuael wrote:
> I don't know of an associative array structure (like AppleScript's record class) which
> would respect some order.
Please ignore that tic in my face as I type the rest of this message.
Applescript records really aren't associative arrays. You can use
code generation and representation parsing (since Applescript keeps
the field labels around for display purposes) to use them as a means
of implementing associative arrays, but you wind up doing a lot of the
work yourself, and it's tricky to get right, especially on the
representation-parsing front.
That said, there are plenty of associative array implementations that
preserve order. PHP arrays are associative and maintain their
insertion order, for instance. Java has an OrderedMap class.
The associative array abstract data type doesn't require order
preservation, and the most efficient implementation uses a hash table,
which doesn't preserve order. Therefore the dictionaries/hashes
available in most scripting languages are not order-preserving. But
that's not a fundamental property of associative arrays in general.
And most of those same languages have libraries (ah, libraries)
available that maintain ordered maps.
For my money, in fact, the biggest missing feature in AppleScript is
not associative arrays, but an easier way to use external libraries.
"load script" would be sufficient if it had some sort of search path
behind it. OSAXen are too stealthy...
--
Mark J. Reed <email@hidden>
_______________________________________________
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