Chip and I have been having a discussion. I want to write: sub foo { my $x = 1; return sub { eval $^codestring } } say foo()("$x");
I claim that that should print 1. Chip claims it should throw a warning about because of timely destruction. My claim is that a closure should close over the entire lexical stack, and not simply those things it uses statically. Chip claims the opposite, arguing that timely destruction implies that this is absolutely the right thing to do. It's also quicker. But dammit, I'm doing runtime evaluation of code strings, I don't care about quicker. If it's not the default can it please be mandated that there be some way of doing: sub foo { my $x = 1; return sub is lexically_greedy {eval $^codestring} } in other words, some way of declaring that a subroutine wants to hang onto every lexical it can see in its lexical stack, not matter what static analysis may say.