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

Re: List Behavior


  • Subject: Re: List Behavior
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Wed, 5 Mar 2008 14:52:12 -0500


On Mar 5, 2008, at 2:38 PM, John Mistler wrote:

I have discovered some peculiar behavior with lists. Can anyone help me understand why?

This works as expected:

set a to {{1, 2, 3}, {"x", "y", "z"}}
set b to item 1 of a
set c to item 1 of a
set c to c & {4}
log b --> {1,2,3}
log c --> {1,2,3,4}

but why does this happen?:

set a to {{1, 2, 3}, {"x", "y", "z"}}
set b to item 1 of a
set c to item 1 of a
set end of c to 4
log b --> {1,2,3,4}
log c --> {1,2,3,4}



Both work as expected ( or as they should be expected to. ).

'set c' binds the name c to an object.

Evaluation of the new object happens before the binding,
so the "c & {4}" on the right-hand-side refers to the old binding.

"b" is still bound to that first object, so "b" and "c" name
two different objects.

'set end of c'  is modifying the object named c by changing the end.
You haven't changed what "b" or "c" point to, but you've changed
the value of that thing by changing it's "end" .


See Lewis Carrol: <http://hubpages.com/hub/Lewis-Carroll> :


Alice was walking beside the White Knight in Looking Glass Land.

"You are sad." the Knight said in an anxious tone: "let me sing you a song to comfort you."

"Is it very long?" Alice asked, for she had heard a good deal of poetry that day.

"It's long." said the Knight, "but it's very, very beautiful. Everybody that hears me sing it - either it brings tears to their eyes, or else -"

"Or else what?" said Alice, for the Knight had made a sudden pause.

"Or else it doesn't, you know. The name of the song is called 'Haddocks' Eyes.'"

"Oh, that's the name of the song, is it?" Alice said, trying to feel interested.

"No, you don't understand," the Knight said, looking a little vexed. "That's what the name is called. The name really is 'The Aged, Aged Man.'"

"Then I ought to have said 'That's what the song is called'?" Alice corrected herself.

"No you oughtn't: that's another thing. The song is called 'Ways and Means' but that's only what it's called, you know!"

"Well, what is the song then?" said Alice, who was by this time completely bewildered.

"I was coming to that," the Knight said. "The song really is 'A- sitting On a Gate': and the tune's my own invention."





-- sdm.




_______________________________________________ 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
  • Follow-Ups:
    • Re: List Behavior
      • From: Christopher Nebel <email@hidden>
References: 
 >List Behavior (From: John Mistler <email@hidden>)

  • Prev by Date: List Behavior
  • Next by Date: Re: Sometime error -10006 copying a folder
  • Previous by thread: List Behavior
  • Next by thread: Re: List Behavior
  • Index(es):
    • Date
    • Thread