• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: minimum function? (Modified by Simon Forster)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: minimum function? (Modified by Simon Forster)
      • From: Axel Luttgens <email@hidden>
    • Re: minimum function? (Modified by Simon Forster)
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: minimum function? (Modified by Simon Forster)
  • Next by Date: Re: minimum function?
  • Previous by thread: Re: minimum function?
  • Next by thread: Re: minimum function? (Modified by Simon Forster)
  • Index(es):
    • Date
    • Thread