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

Re: Why $@ makes me cry (was Re: Generic system() replacements)

Thread Previous | Thread Next
From:
Mark Mielke
Date:
June 25, 2008 06:17
Subject:
Re: Why $@ makes me cry (was Re: Generic system() replacements)
Message ID:
4862456F.9000007@mark.mielke.cc
Mark Mielke wrote:
> Aristotle Pagaltzis wrote:
>>     eval {
>>         # ...
>>     };
>>     if ($@) {
>>         # now you might get here even though
>>         # the `eval` block ran successfully
>>         # ...
>>     }
>>   
>
> I don't think you understood my proposal. Why would the above break? 
> In the case of success in DESTROY, $@ is as expected. In the case of a 
> die escaping DESTROY, $@ will be that die() which is the same as today.
>
> Please explain the problem.

As Jan(?) explained, though - the behaviour is slightly different than 
today. Pople (including me) usually do "eval {}; if ($@) { ... }" which 
doesn't notice that a die() in DESTROY doesn't actually die, but only 
appends to $@. It's not relevant to the above in terms of breakage as my 
real proposal is: If DESTROY dies(), do whatever is done today. If 
DESTROY does *not* die, then restore the old $@ value. In the case of 
your example above, in the case of no die(), $@ would be restored to 
undef/false and at least "$@" would be ok from an analysis perspective.

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