Uri Guttman writes: > talking about nested subs brought up another related idea, static (not > on the stack) lexicals inside subs. the current solution in p5 is to > declare them in a surrounding block and that is slightly ugly. and if > you want multiple subs to share them they all have to be in that > block.
I don't find the Perl 5 approach ugly: I actually like it, because it does exactly what it looks like it's doing, and doesn't require learning any special syntax or keyword. To have a variable exist beyond outside a sub, you declare it outside that sub. To prevent that variable being accessed from anywhere else, you put it in a block. It's simple yet provides the power you need, and it's completely obvious what's going on. Obviously I'd be free to continue doing it this way in Perl 6, but if there's an explicit language feature for doing this then it'd probably make my code seem odd to do so. And merely by having such a feature it's again increasing the amount of Perl that has to be learnt for reading other people's code. Smylers