develooper Front page | perl.perl6.language | Postings from May 2005

Re: Of fail, exceptions and catching

Thread Previous | Thread Next
Aaron Sherman
May 11, 2005 07:36
Re: Of fail, exceptions and catching
Message ID:
On Wed, 2005-05-11 at 09:50, Luke Palmer wrote:

> Oh, just to avoid further confusion: In the baz() called under fatal,
> it will only turn undefs that were generated by "fail" calls into
> exceptions.  Other sorts of undefs will be returned as ordinary
> undefs.

Ok, so let me try to get my head around this:

fail is something like:

	return undef but Exception(...some state info...);

the only question is whether the caller reacts to that special return
value like so:

	if $return ~~ Exception {
		return $return;

or simply ignores it. If you ignore the special return value, then you
presumably have the burden of coping with it in some other way, like so:

	no fatal;
	$socket.bind(:interface<localhost>, :port<80>) or
		$socket.bind(*@defaults) or
			die "Cannot bind: $!";

At the top-level (runtime), you would expect to have something like
(arm-waving some naming specifics):

	given $program.(@args) {
		when Exception { $*ERR.print $_.err; exit 1 }
		default { exit +$_ }

Am I getting it now?

Aaron Sherman <>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About