Re: Arrays in AppleScript ?
Re: Arrays in AppleScript ?
- Subject: Re: Arrays in AppleScript ?
- From: has <email@hidden>
- Date: Wed, 28 Dec 2005 22:05:29 +0000
Mark Lively wrote:
>Concisely AppleScript doesn't have Arrays per se. It has lists which
>are implemented as linked lists.
Incorrect. The standard AS list is a vector, which was introduced circa AS 1.1 IIRC. (The O(n) performance characteristics are due to badly designed safety checking.)
AS does have a linked list type - a holdover from AS 1.0 - but I think this has long been deprecated and isn't something ASers need to know or care about anyway.
>It is possible to force them to be stored as arrays(or it used to be)
Nope.
BTW, note that the term 'array' is often used very loosely; e.g. C array is a _very_ different beast to an NSMutableArray in terms of implementation and behaviour. Calling AS's vector lists 'arrays' isn't really wrong, although it's liable to mislead anyone coming from, say, a VB/C background (since AS's list type is comparable to Cocoa's NSMutableArray class, not primitive VB/C arrays) and confuse ASers who are used to using the official AS terminology (i.e. 'lists').
Paul Berkowitz wrote:
>What's a lot trickier in AppleScript than in some other languages is to insert a new element somewhere in the middle.
Not so much tricky as impossible; you have to create a brand new list by extracting a couple of sub-lists from the original list and concatenating these with the new element. 'Deleting' list items is similarly indirect and tedious. BTW, the List library on AppleMods <http://applemods.sourceforge.net> contains ready-made handlers that will perform this and other basic list operations for you; saves having to roll your own.
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