Re: minimum function? (Modified by Simon Forster)
Re: minimum function? (Modified by Simon Forster)
- Subject: Re: minimum function? (Modified by Simon Forster)
- From: has <email@hidden>
- Date: Wed, 6 Apr 2005 19:15:15 +0100
Axel Luttgens wrote:
>Why do you create a script object to hold the list of numbers? Why don't you access the list of number passed into the function directly? If it's a speed thing, can you explain a but further?
>
>Speed! Just a matter of speed...
Efficiency, to be precise. Not quite the same thing.
>Now, unless I'm wrong, a true explanation for this has never been provided.
Chris Nebel has explained the problem in the past, but I'm not going to hunt through the archives for a link to it. Short version, IIRC:
AppleScript's list objects are implemented as vector lists, which have a constant-time lookup when getting and setting items. It then adds additional error-checking code to this lookup operation that involves scanning every other item in the list, making lookups linear-time; the longer the list. (Note that this is plain brain-deadedness in the AppleScript implementation: other languages manage to implement robust vector lists without compromising efficiency.)
By some unspecified mechanism, this additional checking mechanism is bypassed when using certain reference forms, giving you constant-time lookups again (plus crashes if you're not careful how you do it). There's an obscure mention of this trick in the ASLG, and Emmanuel Levy's [IIRC] script object kludge is the best - or rather, least nasty - way to do it.
HTH
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