MACSCRPT Archives

February 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nigel Garvey <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 6 Feb 2009 10:48:38 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (38 lines)
Ryan Wilcox wrote on Thu, 5 Feb 2009 21:40:20 -0500:

>On Feb 5, 2009, at 6:03 PM, Deivy Marck Petrescu wrote:
>> ... modifying a string and then creating a huge list.
>> But still, the second is playing with a list from the outset.
>> I believe a while ago Chris Nebel put a god explanation on why lists  
>> require more "work" in the Apple AppleScript list.
>> If one does away with the need of manipulating a list but instead  
>> uses a reference to the list then the situation changes dramatically:
>>
>> repeat 10000 times
>> 	set end of (a reference to c) to "a"
>> end repeat
>> set t3 to (current date) - t2
>
>
>EXCEPT the "reference to"  trick ONLY works in the (implicit or  
>explicit) run hander (because that's the only place you can explicitly  
>create a reference in AppleScript, which I mention in my article.  
>Well, unless you make c a property - then you can use it as a reference.

A now-famous trick is to reference a property of a script object, which
works locally:

  on myHandler()
    script o -- o is local to myHandler.
      property c: {}
    end

    repeat 10000 times
      set end of o's c to "a" -- o's c instead of c of «script»
    end repeat

  end myHandler


NG

ATOM RSS1 RSS2