On Mon, Nov 29, 2010 at 9:39 PM, Zefram <zefram@fysh.org> wrote: > The generation of optimised constant subs is a useful facility. > It certainly ought to be available, without having to invoke the > installation-in-a-package behaviour of "use constant". But this exception > to the closure rules is a poor way to make it available, since it breaks > an otherwise logically consistent language feature. In my opinion, > constant-sub creation should be made available via an XS function in some > CPAN module (very easily arranged), and the magic behaviour of sub(){$x} > should be phased out (less easy, probably requiring a deprecation cycle). There is no reason constsubs can't close over a variable, they just wouldn't be very const if they did. The implementation currently deliberately breaks closures (in op_const_sv it seems), and the optimizer would make assumptions it shouldn't for such subs, but other than that it is already supported right now. It may make sense to explicitly support 'svsubs', which are like constsubs except that they don't fold to a constant. LeonThread Previous