Re: RFC from a newbie: Method References

[email protected] ((Randal L. Schwartz)) 16 Dec 2000 09:29:18 -0800
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
>>>>> "Ian" == Ian Hickson <[email protected]> writes:

Ian> So: What I would love to see in Perl 6 is a way of having a single scalar
Ian> that holds a reference to a particular instance's method.

Ian> Is there any chance that this would be considered? Or is this already
Ian> possible in Perl 5 but I have missed it?

  my $methref = sub { $foo->method(@_) };

You missed it. :)  Just be sure that $foo is not a package variable,
so that a proper closure is created.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!