develooper Front page | perl.perl5.porters | Postings from September 2013

Re: [perl #120047] perl should enable "$_" for use before callingsubs

Thread Previous | Thread Next
From:
Lukas Mai
Date:
September 29, 2013 20:24
Subject:
Re: [perl #120047] perl should enable "$_" for use before callingsubs
Message ID:
52488C5A.8070506@gmail.com
On 29.09.2013 21:44, Linda Walsh via RT wrote:
> On Sun Sep 29 04:43:25 2013, LeonT wrote:
>> On Sun Sep 29 02:26:28 2013, LAWalsh wrote:
> 
>>> Regardless of documentation that may justify this behavior, I would
>>>    like to
>>> see the design reasons for this behavior if such is to be found.
>>> I see no logic in disabling $_, **randomly*** (based on callstack) in
>>> a sub-function or library call but allowing it for built-ins. 
> ----
>> When using $_ in a subroutine and you do not want it to affect or or be
>> affected by the calling environment, you should use local on it. Or
>> better yet, just use a lexical variable. Not doing so is a bug, your
>> bug. Perl is behaving as intended and expected.
> ----
> 
>> Closing this as not-a-bug
> -====
> As I said, referring to current behavior or saying that the current
> buggy behavior is "by design", doesn't mean it isn't a bug.  That you
> didn't understand that basic premise is typical of one who engages in
> unthinking behavior in order to close bugs (not that you always do, but
> *often* do).
> 
> If you can show what would be harmed by my change, I'll accept it as not
> being a bug.  Otherwise, I assert you've placed a needless restriction
> on library code -- that all of them must use "local" $_ --
> which may be completely inappropriate, especially given that the
> locality of $_ isn't preserved across lateral transfers of control made
> with "goto".

I don't understand what your original bug report was about. I found it
too long and confusing and stopped reading halfway through. What exactly
is your proposed change?

But regarding library code: If your library code blindly modifies global
variables (such as $_), it's probably broken.

-- 
Lukas Mai <plokinom@gmail.com>

Thread Previous | 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