Here's my short test code which demonstrates the data structure prior to returning and how it instamagically turned into a self-ref afterward.
Here's the data before returning and after returning it from the -= method.
$expected = bless( \bless( \1, 'T' ), 'T' ); $got = bless( \$got, 'T' );
And here's the sample code.
package T; use Data::Dump::Streamer; sub D { my ( $name, $val ) = @_; Dump() ->Purity( 0 ) ->Names( $name ) ->Data( $val ) ->Out(); return; } use overload( '-=' => sub { my $new = bless \ $_[0], "T"; D( new => $new ); return $new; }, '""' => sub { my $self = shift; D( self => $self ); return $$self } ); sub new { my ( $class, $val ) = @_; bless \ $val, $class; } package main; $o = T->new( 1 ); $o -= 2; "$o";
In reply to Re^2: A warning about overloading assignment methods
by diotalevi
in thread A warning about overloading assignment methods
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |