>>>>> "TM" == Tom Metro <[EMAIL PROTECTED]> writes:
TM> Isn't there also a potential problem if the if something upstream of the
TM> reblessing saves a reference to the object, or is this true:
TM> use Scalar::Util 'refaddr';
TM> my $obj = {};
TM> my $before = refaddr($obj);
TM> my $newobj = bless($obj, 'foo');
TM> print "true\n" if $before eq refaddr($newobj);
TM> Perl says it is. Makes sense, as although bless returns an object, it
TM> shouldn't create a new one.
as damian says, bless actually blesses the referenent, not the
reference. the underlying anon hash has 'foo' put into its 'bless'
slot. refs only point to the underlying thing which has the data and the
bless value. so reblessing will cause all refs (actually nothing happens
to the refs) to see the new blessed class. a ref only really has a
pointer to the referent which has the data, type and bless value (and
ref counts and more).
uri
--
Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm