On 5/11/05, Aaron Sherman <[EMAIL PROTECTED]> wrote: > Given: > > "fail" with configurable behavior > "no fatal" to make "fail" just warn
Juerd is right here, it doesn't warn. Instead of "die"ing, it returns an undef with some helpful diagnostic information (an "unthrown exception" as Larry has been calling it). > "use fatal" to make "fail" throw exceptions > > A question came up on #perl6 for the following code: > > no fatal; > class Foo { > use fatal; > method bar() { fail; } > } > Foo.bar; > > That is, bar() picks up a lexically scoped "use fatal" No it doesn't. The fatal that refers to bar's return value belongs to the caller of bar. Here's another example: sub foo() { fail; } use fatal; sub bar() { foo(); # foo() throws exception } no fatal; sub baz() { foo(); # foo() returns undef } use fatal; bar(); # propagates exception from foo() baz(); # turns baz()'s (from foo()'s) undef into an exception no fatal; bar(); # turns exception thrown from foo()'s into an undef baz(); # returns the undef that it got from foo() Does that clarify things? (I could tell there was some misunderstanding going on, but I had a hard time explaining it. Hopefully this example will clear things up) Luke