Damian Conway writes:
> There's no need for special methods or (gods forbid) more operators.
> Just:
> 
>     $obj1.id == $obj2.id
> 
> That's what the universal C<id> method is *for*.

How universal are universal methods?

That is, can a programmer override .id() in a user-defined class?  If so,
simply comparing .id for numeric equality isn't a good enough way of
comparing object identity.  I think you'd have to do something like

  $obj1.UNIVERSAL::id == $obj2.UNIVERSAL::id

which is getting fairly verbose.  But I also have a feeling of non-specific
unease at the idea that I might _not_ be able to override a universal
method.

Another question.  Consider the integer 17.  There are two plausible
representations for it -- one boxed, and one unboxed.  There might also
be several distinct boxed 17s that aren't object-identical.  My question
is whether all of those should have the same .id().  That is, should the
programmer be allowed to determine whether two apparently-identical
numbers have the same representation, or should .id() fudge the issue by
pretending that all representations of a number of a given type are
identical.

-- 
Aaron Crane * GBdirect Ltd.
http://training.gbdirect.co.uk/courses/perl/

Reply via email to