Michael Lazzaro <[EMAIL PROTECTED]> writes:

> 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

I like this. Gets 'round needing a million and one different equality
operators. If you find yourself using a particular form more often
than others then just write yourself an operator.

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?

Reply via email to