develooper Front page | perl.perl5.porters | Postings from October 2011

Re: Are exceptions "still broken" in core Perl?

Thread Previous | Thread Next
From:
Joshua ben Jore
Date:
October 25, 2011 20:21
Subject:
Re: Are exceptions "still broken" in core Perl?
Message ID:
CAHmienduF2JPJ1818iAFVGKKmWaFAKn3B-rtn69wdfQwQ+duTg@mail.gmail.com
That only works as long as your '1' hasn't been rewritten as an
overloaded literal.

    use bigint;
    eval {
        ...
        1; # secretly, an object which will have ->
    } or ...;

There's really nothing you can count on.

On Tue, Oct 25, 2011 at 8:09 PM, Chas. Owens <chas.owens@gmail.com> wrote:
> On Tue, Oct 25, 2011 at 18:42, David Nicol <davidnicol@gmail.com> wrote:
>>
>>
>> On Tue, Oct 25, 2011 at 9:39 AM, Zefram <zefram@fysh.org> wrote:
>>>
>>>  I think the best
>>> available approach is
>>
>> I like the practice of separating the questions
>> "did the block succeed?" from "what was the exception?"
>> by ending the eval block with 1 instead of testing $@.
>> unless(eval { ... ; 1}){
>>         ... #catch
>> }
>>
>> --
>> "Unacceptable: Little cartoon boy micturating on Fedora logo" -- fedora
>> project trademark guidelines
>>
>
> I always liked
>
> eval {
>    #do stuff that may die
>    1;
> } or do {
>    #catch
> };
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.
>

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