Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Object Suicide

by ChemBoy (Priest)
on Jun 15, 2007 at 20:00 UTC ( #621511=note: print w/ replies, xml ) Need Help??

in reply to Object Suicide

What you're trying to do here is definitely possible, though I'm not sure it's advisable. The key is that you can't use the standard my $self = shift; boilerplate in that method, because that makes a copy of the caller's reference, rather than operating on it directly (this is usually a good thing). Rather, it would need to look something like the below:

sub method_which_may_suicide { my ($self,@arglist) = @_; if (_should_suicide(@arglist) ) { undef $_[0]; } }

Note that this will only destroy the reference in the immediate calling code—if you call this from another method that uses the my $self = shift; trick, it will not propagate the change to whoever called that method. And again, <symbolic hand-washing>I'm not advising you to do this, but it's there if you want it</symbolic hand-washing>. :-)

If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders

Comment on Re: Object Suicide
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://621511]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2015-11-28 13:48 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (742 votes), past polls