in reply to return eval { die() } idiom

So the callers do something like the following?
myfunc() or print "something bad in myfunc $@\n";
Instead of:
eval { myfunc() } or print "something bad in myfunc $@\n";
I haven't seen this in Perl, that I recall.

It might make sense sometimes, but I suspect that with 2 or more levels of calling functions you end up doing a whole lot of re-die-ing.

Interesting anyway.

Replies are listed 'Best First'.
Re: Re: return eval { die() } idiom
by dragonchild (Archbishop) on Sep 02, 2003 at 15:43 UTC
    Personally, I do something like:
    sub x { # stuff eval { # eval-ed stuff }; if ($@) { die $@ unless UNIVERSAL::isa($@, 'ErrorOrSignalThatICanHandleH +ere'); # Handle the error/signal types I can handle here however I se +e fit }; return 1; }

    Of course, this assumes a library of error and signal classes, but, then again, if you're using eval-die as a throw-catch mechanism, you would have those, right?

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.