develooper Front page | perl.perl5.porters | Postings from March 2008

Re: local $@ has an unwanted side effect

Thread Previous | Thread Next
From:
Mark Mielke
Date:
March 21, 2008 17:21
Subject:
Re: local $@ has an unwanted side effect
Message ID:
47E450E7.2040701@mark.mielke.cc
David Nicol wrote:
> On Fri, Mar 21, 2008 at 6:13 PM, Mark Mielke <mark@mark.mielke.cc> wrote:
>   
>>  Does this explain it Dave?
>>
>>     
>
> but that doesn't work either; the problem is that $@ gets unlocalized after
> eval assigns to it, even when the argument to die has nothing to do with $@.
>
>
>     perl -le 'eval { local $@; die "yabbazabba" }; print $@||"nothing there"'
>
> So including an attempt at pass-by-copy in the documentation of what
> doesn't work (1) indicates that thinking it might be a pass-by-copy problem
> is reasonable and (2) documents by example quoting as a method to force
> pass-by-copy.
>   
I see what you mean now. Yes, I've hit this too. I may have 
misunderstood the original problem as well. The issue being, that die 
stores to $@ before $@ is restored to its original value, making the die 
unavailable. If this is the original problem, then yes, it's not a 
pass-by-reference problem, but a local vs my problem. When I hit the 
above issue before, my conclusion was that local was the wrong choice 
for $@ and that my would have worked a lot better(?). But again, a "too 
late now, don't complain, just move on" is the route I took.

Cheers,
mark

-- 
Mark Mielke <mark@mielke.cc>


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