• 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: Dates gone wild
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dates gone wild


  • Subject: Re: Dates gone wild
  • From: Helmut Fuchs <email@hidden>
  • Date: Tue, 9 Sep 2003 14:30:12 +0200

Are you saying that "set end of ls to d" really means "place a reference to d at the end of ls"?
No. It's not a reference in AppleScript terms.

What happens here, is a side effect of data sharing (described from page 206 in the ASLG). When using 'set', only a handle to the data is copied. The data itself remains as is (I don't know whether there is data, that IS copied, but that is of no importance as you'll see below). Data sharing really takes place on the machine's memory address level (or at least very close to that, as garbage collection and stuff have to be handled as well).

When you use 'copy' then all values are copied (if my memory is correct, then a deep copy is performed).

The effects of data sharing are only visible for mutable values/objects, i.e. values/objects whose content can be changed - like accessing items of a list, or setting different aspects of a date value. For values/objects that can only change through assignment, like numeric values and strings, data sharing never becomes obvious, because their content can't be changed.

References on the other hand, are special AppleScript records, which contain phrases like "item x of y of z" in an encoded form and are interpreted at runtime - they're not a pointer, they are merely path descriptions.

If they were pointers in the classical sense, the following example would give the message "Hi!" two times:


set x to {a:{b:{c:"Hi!"}}}
set z to {b:{c:"Bye!"}}

set y to a reference to c of b of a of x
display dialog (y)

set a of x to z
display dialog (y)
<<

HTH,

Helmut
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Facespan 4.0 in public beta
      • From: "John C. Welch" <email@hidden>
References: 
 >Re: Dates gone wild (From: Nigel Garvey <email@hidden>)
 >Re: Dates gone wild (From: Doug McNutt <email@hidden>)

  • Prev by Date: Re: Dates gone wild
  • Next by Date: lots of statements after "then" of "if"
  • Previous by thread: Re: Dates gone wild
  • Next by thread: Facespan 4.0 in public beta
  • Index(es):
    • Date
    • Thread