Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Wednesday June 27, 2007
09:36 AM

Returning data while dying

[ #33614 ]

Someone asked me about one of their coworkers who wrote something conceptually similar to this:

sub set_and_die {
    $_[0] = 7;
    die "ha!";
}

my $val = 'Ovid';
eval { set_and_die($val) };
print $val;

The actual code is in C# and he throws an exception and sets a value (via an "out" parameter). Then the calling code (on the receiving end of a Web service), has to examine the exception to figure out if the value is safe to use or not (I have visions of huge case statements examining magic variables in "object oriented" code).

Wow. Just wow. You return data or you throw an exception and ne'er the twain shall meet. At least, that's what I thought. Can you think of any reason this wouldn't be a a phenomenally bad idea?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.