On Tue, 1 Apr 2003, Michael Lazzaro wrote:
> On Tuesday, April 1, 2003, at 10:35 AM, John Williams wrote:
> > On Tue, 1 Apr 2003, Michael Lazzaro wrote:
> >> So I would imagine it _is_ possible to test that two values "have the
> >> same identity", but I would imagine it is -not- possible to actually
> >> get what that identity "is". There's no .id method, per se, unless
> >> you
> >> create one yourself.
> >
> > What about the \ (reference) operator? If you take two references to
> > an
> > object, they should compare the same, right?
>
> In theory, I would think so. But in P6 practice, that might not be as
> useful as it sounds:
>
> my @a;
> my @b := @a; # bind @b same as @a
>
> [EMAIL PROTECTED] == [EMAIL PROTECTED]; # true, but not for the reason you
> think!
> @a =:= @b; # true, are bound to the same array
You're right, but personally, I have come to trust eq more that == when
comparing things-which-might-not-be-numbers, such as references.
[EMAIL PROTECTED] eq [EMAIL PROTECTED]; # true, for the reason I think
# (the string-representation of the refs are equal)
> [*] (Also, any identity test that relies on numerification or other
> transformation of the comparators is doing a lot of unnecessary work.)
Quite true. But if we can agree that the reference is by necessity a
unique identifier for the object (or the container, at least), then a
$obj.id method which returned a numified reference value would do what you
want without unnecessary work (stringification) or unexpected results
(numification yields the length), Yes?
~ John Williams