a while back I wrote a piece of code that was basically a generic
equals method for objects. I'm wondering if I patched moose to give
objects this functionality if it'd be accepted?

basically it was something like

refaddr ==
blessed?
isa?
...

and a few more checks, the external interface was

1 classes are equivalent
0 classes are definitely not equivalent
undef superclass/unmodifed method says it's not equivalent but it
still could be determined to be equal by a subclass.

this method would make it easier to do simple equals methods on things
like entities, for example:

override equals => sub {
      my ( $self, $obj ) = @_;

      my $ret = super();
      if ( ! defined $ret ) {
           return 1 if $self->id == $obj->id;
      }
      else {
          return $ret;
      }
      return undef;
};

and of course you could just completely redefine it.
--
Caleb Cushing

http://xenoterracide.com

Reply via email to