MACSCRPT Archives

May 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:
"Mark J. Reed" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 20 May 2009 10:29:13 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (50 lines)
Concatenation is the wrong way to build up a list anyway, if you're
adding an item at a time.  The "set end of" approach is always the way
to go, whether it's records or something else.
    It's a question of efficiency - if you add an item to the end of a
long list by concatenation using "set mylist to mylist & {mynewitem}",
AS first makes a copy of the whole list, adds the new item to the
copy, changes the variable to point to the copy instead of the
original, and then marks the memory space used by the original as
available.  So it temporarily takes up twice the memory it really
needs and does a lot of unnecessary copying.  "Set end of" modifies
the list in place.
   List concatenation is more for combining two lists that might
already have multiple items each.

On 5/20/09, Bill Steele <[log in to unmask]> wrote:
>>>Works for me too.  Thanks.
>>>
>>>I wonder where it says that in the Applescript Language Guide.
>>>
>>Hi Bill,
>>
>>It says right there on page 187 (the newest version)
>><quote>
>>record
>>The concatenation of two records joins the properties of the
>>left-hand record to the properties of the right-hand record. If both
>>records contain properties with the same name, the value of the
>>property from the left-hand record appears in the result. For
>>example, the result of the expression
>>
>>{ name:"Matt", mileage:"8000" } & { name:"Steve", framesize:58 }
>>
>>is
>>
>>{ name:"Matt", mileage:"8000", frameSize:58 }
>></quote>
>
> Yep, I found that. It just doesn't say how to fix it. Fortunately,
> there's always someone on this list who does.
> --
>
> Bill Steele
> [log in to unmask]
>

-- 
Sent from my mobile device

Mark J. Reed <[log in to unmask]>

ATOM RSS1 RSS2