in reply to Memoize collision with objects

Overloading stringification would certainly be one approach.  Another possibility might be to (mis)use the NORMALIZER option. Quoted from the docs:

(...) supply a NORMALIZER function that turns the program arguments into a string in a way that equivalent arguments turn into the same string.

Now, the idea would be to supply a function that turns non-equivalent arguments (i.e. object instances which are different, despite residing at the same (recycled) address) into different strings, e.g. by having some unique ID associated with each object (attribute assigned upon construction), which you then somehow munge into the string returned by the normalizer function... Just an idea.

Replies are listed 'Best First'.
Re^2: Memoize collision with objects
by jeteve (Pilgrim) on Nov 12, 2008 at 12:37 UTC
    Hi,

    I actually added a unique id to all my instances, and it solves the problem:

    sub bar{ my ( $self, etc .. ) = @_; return $self->_memBar($self->id(), etc ...); } memoize('_memBar') ; sub _memBar{ my ( $self , $id , etc .. ) ; .. do the real stuff .. }