.WHAT gives you the actual type, whereas .^name gives you a string
that is the name.
In Perl6 types are things you can pass around; which is good because
you can have more than one with the same name.
sub bar (){
my class Foo { }
}
sub baz (){
my class Foo { }
}
Brandon Allbery wrote:
> Two issues:
>
> (1) all standard exceptions are in or under the X:: namespace.
>
> (2) .WHAT doesn't show names with their namespaces, whereas .^name does.
>
> pyanfar Z$ 6 'my $r = 4/0; say $r; CATCH {default {say .^name}}'
> X::Numeric::DivideByZero
Thanks. I didn't
I was just looking into doing some finer-grained exception handling,
so I tried this:
use v6;
try {
my $result = 4/0;
say "result: $result";
CATCH {
#when DivideByZero { say "Oh, you know."; }
default { say .WHAT; .Str.say } # (DivideByZero)