• 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: set vs copy?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set vs copy?


  • Subject: Re: set vs copy?
  • From: Alex Zavatone <email@hidden>
  • Date: Tue, 14 Sep 2010 18:08:25 -0500

Try it with list values.

On Sep 14, 2010, at 6:05 PM, Bruce Robertson wrote:

> I tried to create an example but it didn't work. Maybe you can provide a variation that does illustrate the difference?
>
> Set A to "A"
> Set B to A
> Copy A to C
> Set A to "B"
> {B, C}
>
> -- result:  {"A", "A"}
> -- thought it shoulda been {"B", "A"}
>
>
> On Sep 14, 2010, at 3:38 PM, Shane Stanley wrote:
>
>> On 15/9/10 7:01 AM, "tom wible" <email@hidden> wrote:
>>
>>>> For paranoia's sake, I used copy, but I'm sure a set will do the
>>>> trick.
>>>
>>> i've never seen a satisfactory explanation of exactly what a/s is
>>> doing in set vs copy...
>>
>> Copy makes a complete copy of what a variable refers to, whereas set just
>> makes another variable pointing to the same stuff in memory.
>>
>> For mutable classes like list, record and date, having more than one
>> variable point to the same chunk of memory means that if you modify the
>> contents of one of these variables, any others pointing to the same chunk of
>> memory will also return the new value. This can be avoided, where necessary,
>> by using copy to make an entirely separate, um, copy.
>>
>> For immutable classes like text, real, etc, the fact that more than one
>> variable can point to the same chunk of memory is irrelevant, because the
>> contents can't be modified once it's created anyway. So doing a copy in such
>> cases is just wasting time and memory.
>>
>> --
>> Shane Stanley <email@hidden>
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: set vs copy? (From: Shane Stanley <email@hidden>)
 >Re: set vs copy? (From: Bruce Robertson <email@hidden>)

  • Prev by Date: Re: set vs copy?
  • Next by Date: Re: Illustrator CS4 hierarchical menus
  • Previous by thread: Re: set vs copy?
  • Next by thread: Re: set vs copy?
  • Index(es):
    • Date
    • Thread