• 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: list question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: list question


  • Subject: Re: list question
  • From: Chris Page <email@hidden>
  • Date: Wed, 4 Jun 2003 17:23:56 -0700

On Wednesday, Jun 4, 2003, at 16:41 US/Pacific, Chris Page wrote:

The meaning of 'set' depends on what's between the 'set' and the 'to':

set a to 1 -- bind a to the immutable integer 1

Another example I should have included is:

set a to a reference to item 2 of {"A", "B"}
-- bind a to the reference
set a to "X" -- bind a to immutable string "X"
--> "X"

It's important here to see that 'set a to "X"' is exactly the same as in the first example, 'set a to 1', regardless of the fact that 'a' is first bound to a reference. The left-hand side of 'to' is the variable (binding) 'a', so 'set' binds 'a' to the right-hand side.

I point this out because references can seem to complicate things, but as you can see here, they don't affect the meaning of 'set'.

In order to set the contents of the reference, you have to explicitly use 'set' with a left-hand side that is a specifier for the contents of the reference:

set a to a reference to item 2 of {"A", "B"}
-- bind a to the reference
set b to a -- bind b to the same reference
set a to "X" -- bind a to immutable string "X"
set contents of b to "X" -- mutate the mutable list {"A", "B"}
{a, b}
--> {"X", item 2 of {"A", "X"}}

Especially note that references are objects. They can be bound to variables just like any other object. They are not treated differently in this regard. By the way, references are immutable objects, regardless of whether the object they refer to is mutable.

--
Chris Page - Software Wrangler - Palm, Inc.

Go to MacHack...or die trying: <http://www.machack.com/>
_______________________________________________
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.

References: 
 >Re: list question (From: Chris Page <email@hidden>)

  • Prev by Date: Re: list question
  • Next by Date: Re: can't 'tell' specific version of application (filemaker pro)
  • Previous by thread: Re: list question
  • Next by thread: Re: list question
  • Index(es):
    • Date
    • Thread