• 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: More about Records
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More about Records


  • Subject: Re: More about Records
  • From: email@hidden
  • Date: Thu, 4 Jan 2001 00:54:11 -0500

On Tue, 02 Jan 2001 11:57:31 -0800
Paul Berkowitz <email@hidden> asked,

> Would someone like to explain what's going on here?
>
> set r1 to {a:1, b:2, c:3}
> set r2 to {a:1, b:2, c:75}
>
> r1's {a, b}
> -- {1, 2}
> r2's {a, b}
> -- {1, 2}
> r1's {a, b} = r2's {a, b}
> -- false
> {r1's a, r1's b} = {r2's a, r2's b}
> -- false
> r1's a = r2's a and r1's b = r2's b
> -- true

The expression "r1's {a,b}" is a reference. (You can assign to it, so it must
be. "set r1's {a, b} to {10, 66}" works fine.)

And the rules for comparing references is essentally that they are identical
(equal classes, equal reference forms and equal containers). That they refer to
identical things isn't even enough. And in this case, the references refer to
different things.

Its sometimes tricky to see when things are references, since if you ask for the
class of one, it gets its contents evaluated. This is related to the old
"comparison inside a 'repeat with' loop" problem.

set primes to {2,3,5,7,11}
repeat with aPrime in primes
if 7 is aPrime then display dialog "Seven is too a prime!"
end repeat

and you see no dialog. That's because aPrime on the fourth iteration isn't 7,
but "item 4 of {2,3,5,7,11}". Because "is" doesn't force the reference to spit
out its contents, the comparison becomes a number compared to a reference. And
if the classes aren't the same, the result is always false.

--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden


  • Follow-Ups:
    • Re: More about Records
      • From: "Serge Belleudy-d'Espinose" <email@hidden>
  • Prev by Date: Re: resetting record values to ""
  • Next by Date: Akua spawn examples?
  • Previous by thread: Re: More about Records
  • Next by thread: Re: More about Records
  • Index(es):
    • Date
    • Thread