develooper Front page | perl.perl5.porters | Postings from January 2022

Can't localize lexical variable $x at ...

Thread Next
January 25, 2022 14:25
Can't localize lexical variable $x at ...
Message ID:
Why can't we? I think I might have known the answer once, but if I did
I no longer recall it.

I think of local() as "temporarily replace the value at this lvalue
with a new value, restore it at the end of the current lexical scope".
This is hugely useful in many situations that would otherwise require
more and slower code with much more opportunity for error.

Is there a technical reason why it would not be possible to implement?
Or is it that we're worried it would be confusing for users? Or is it
only that way back when (around 5.0, I guess) nobody thought it would
be useful?

Is it something we would ever consider changing?


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