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

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

Thread Next
From:
hv
Date:
January 25, 2022 14:25
Subject:
Can't localize lexical variable $x at ...
Message ID:
202201251320.20PDKHP22919@crypt.org
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?

Hugo

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About