On Wednesday, December 11, 2002, at 10:36 AM, John Siracusa wrote:
> Maybe "AS_STRING" and "AS_STRING_DEBUG"? Too long? "DEBUG_STRING"? > Are we married to the "AS_*" thing?
Not really -- whatever works. We also had .debug, .identity, and .id proposed, for example.
>> You shouldn't be stringifying objects merely to test if they're the >> same object -- yuck. It was an artifact of Perl5 that we should be >> replacing.)
> So, what is the Perl 6 way to test this?
I was hoping someone would ask that. :-) We don't _have_ a way, AFAIK. It was discussed briefly during the operator thread, but without decision. We know:
$obj1 == $obj2; # compares them numerically
$obj1 eq $obj2; # compares them stringically
We could override either C<==> or C<eq> of C<Object> to do it. Then we have to ask what happens if you say:
$obj == 5;
$obj eq 'foo';
That would hopefully *not* compare the identity of $obj to either 5 or 'foo', but instead Do The Right Thing (numerify or stringify $obj). So presumably, this is a job for multimethod variants of class-specific C<==> or C<eq> operators. Well, sortof.
OR, you just explicitly compare the identities, e.g.
$obj1.identify == $obj2.identity; # yuck
OR, we have a third kind of comparision operator, like perhaps '==='.
$obj1 eq $obj2; # are their stringifications identical?
$obj1 == $obj2; # are their numifications identical?
$obj1 === $obj2; # are they in fact the same object?
The triple '===' being vaguely reminiscent of Unicode '≡'.
MikeL
- Stringification of references (Decision, Please?) Michael Lazzaro
- Re: Stringification of references (Decision, Please... John Siracusa
- Re: Stringification of references (Decision, Pl... Michael Lazzaro
- Re: Stringification of references (Decision... John Siracusa
- Re: Stringification of references (Decision... Piers Cawley
- Re: Stringification of references (Decision, Please... Luke Palmer
- Comparing Object Identity (was: Re: Stringifica... Michael Lazzaro
- Re: Comparing Object Identity (was: Re: Str... Michael G Schwern
- Re: Comparing Object Identity (was: Re:... Dan Sugalski
- Re: Comparing Object Identity (was: Re: Str... Dave Whipp
- Re: Comparing Object Identity (was: Re:... Damian Conway
- Re: Comparing Object Identity (was... John Siracusa
- Re: Comparing Object Identity ... Luke Palmer