On Tue, Apr 12, 2005 at 01:24:58PM -0000, Nicholas Clark wrote:

> reblessing a object in a overloaded class doesn't clear the magic on some
> condition.
> Compare delete with delete_with_self in the test case.

It looks like it's a more fundamental problem of where the overloading flag
is stored:

#!/usr/bin/perl -w
use strict;
package Foo;

use overload
        bool     => sub { 0 };

sub quack {
  print "quacks like a Foo\n"
}
package main;

my %hash;

my $o1 = \%hash;
my $o2 = \%hash;
bless $o1, 'Foo';

print $o1 ? "o1 true\n" : "o1 false\n";
print $o2 ? "o2 true\n" : "o2 false\n";
$o2->quack();
__END__
o1 false
o2 true
quacks like a Foo


To make things work, it needs to be on the referent, not the reference.

Nicholas Clark

Reply via email to