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!)
|
|---|