Re: list question
Re: list question
- Subject: Re: list question
- From: Doug McNutt <email@hidden>
- Date: Wed, 4 Jun 2003 11:09:56 -0600
At 21:11 -0700 6/3/03, Chris Page wrote, and I snipped:
>
- variables are names for objects
>
- objects can have multiple names
>
set a to "A" -- a is bound to the immutable string "A"
>
set b to a -- b is bound to the same immutable string "A"
>
set c to a & "B" -- c is bound to a new immutable string "AB", constructed
>
by copying the contents of "A" and "B"
>
set a to c -- a is bound to the immutable string "AB"
set a to 2
set b to a
set c to a + b
c
--> 4
set a to a + 1
set c to a + b
c
--> 5
Can you explain just how "b" here refers to the same object as "a". Why doesn't the second calculation return 6? (I'd really be upset if it did!)
Did not "set a to a + 1" mutate the object to which a refers? Is there an immutable value 2 that still exists after I add the 1? I should hope the memory would be reused.
Does "set" in AppleScript mean the same as "Let" in original BASIC? Or does it work like "set" in M$ VBA where it assigns a local name to, say, a range of cells in an Excel workbook? Both BASIC and VBA use a simple = sign to store a value in memory identified by named variable. A := construct is used elsewhere. AppleScript doesn't allow either but does it replace the (:)= with "set"? Or does it have two separate meanings for "set"?
How, in this brave new world of objects does one take a derivative of a variable that is a function of time? Perhaps it is read from a voltmeter with direct memory access. The immutable object mutates by itself.
--
--> There are 10 kinds of people: those who understand binary, and those who don't <--
_______________________________________________
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.