develooper Front page | perl.perl6.language.objects | Postings from December 2000

Re: RFC from a newbie: Method References

Thread Previous | Thread Next
From:
merlyn
Date:
December 16, 2000 09:29
Subject:
Re: RFC from a newbie: Method References
Message ID:
m1r938ff69.fsf@halfdome.holdit.com
>>>>> "Ian" == Ian Hickson <ian@hixie.ch> 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
<merlyn@stonehenge.com> <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!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About