develooper Front page | perl.perl5.porters | Postings from July 2009

Re: Brainstorming 5.12 syntax features

Thread Previous | Thread Next
July 16, 2009 12:16
Re: Brainstorming 5.12 syntax features
Message ID:
2009/7/16 David Nicol <>:
> On Thu, Jul 16, 2009 at 9:51 AM, Rafael
> Garcia-Suarez<> wrote:
>> Ah, so you were making the assumptions that the sub to call is known
>> at compile time and that it would never change during the lifetime of
>> the program. This is Perl, so those are wrong assumptions :)
> anyone for "local sub" shorthand?
> $ perl -le 'sub X {"outer"} { local sub X {"inner"} print &X } print &X'
> could become equivalent to
> $ perl -le '*sub X {"outer"}; { local *X = sub {"inner"}; print &X } print &X'

One problem with the bottom on older perls is it resets the method
cache for all methods, twice.

In newer perls I think things are better, I dont know how much.

The only need for this that i know of is if you dont have
Scalar::Utils::weakref() available for some reason, and you need to do
a recursive closure. And i personally think that case is much easier
to solve, (already (mostly?) solved actually thanks to rafael), by
having a symbol which always refers to the current sub, without
modifying the subs refcount. Which is more or less provided by


perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About