Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Rea: Invoke object methods with a symbolic reference

by baku (Scribe)
on Feb 14, 2001 at 19:59 UTC ( #58365=note: print w/replies, xml ) Need Help??

in reply to Re: Invoke object methods with a symbolic reference
in thread Invoke object methods with a symbolic reference

You could do the same by generating a closure to pass it $a == $self:

sub new { my $self = {}; bless $self, $_[0]; $self->{f} = sub { &foo ($self, @_); }; return $self; }

The only reason for the three-line form with temporary variable is that I can't figure out how else to embed the closure "reference" to the object ($self) inside of an hash inside of the object itself :-)

(fixed minor typo!)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://58365]
[virtualsue]: Aha. My crawler didn't deal properly with hrefs starting with ?
[Discipulus]: 1nickt maybe 'cause you ignore what happened in middleage in real monasteries... ;=)
[Corion]: virtualsue: Aaah, yes, we do use these a lot

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-12-13 13:57 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (368 votes). Check out past polls.