On Fri Jun 15 05:41:40 2012, LeonT wrote: > On Tue May 17 06:23:23 2011, davem wrote: > > The other bit of information missing is that inner anon subs hold a > > reference to their enclosing sub, so any outer sub (anon or otherwise) > > doesn't normally get freed until the inner sub has been freed. > > But is there any conceptual reason why it has to do this? Why can't it > just keep the variables in encloses alive instead? > > > So I don't think its a bug, nor do do I think the behaviour should be > > changed. > > I do think this is a misfeature, and I would like to see it changed: it > makes working with nested closures unnecessarily complicated. I have just been bitten by the same thing. So I wrote a patch. It is only eight lines (excluding tests). Ignoring the new flag I added to cv.h, it is only three lines of changes. Can Dave Mitchell please comment? As far as I can tell, CvOUTSIDE is only used during compilation when looking up variables. So at run time we only need it if there is a string eval. However, we might have to close over $_ even when it appears unused for UNDERBAR to work. But that is already partially broken. -- Father Chrysostomos --- via perlbug: queue: perl5 status: rejected https://rt.perl.org:443/rt3/Ticket/Display.html?id=89544Thread Previous | Thread Next