The anon does something. For example this code prints "bob"

my $routine = proto bar (|) { * };
multi bar (Int $x) { $x - 2 }
multi bar (Str $y) { $y ~ 'b' }

say $routine('bo');

but change the first line to "my $routine = anon proto bar (|) { * };" and
you get an error

Cannot call 'bar'; none of these signatures match:
  in block <unit> at type.p6:5

- and that makes sense to me, because "anon" means no name gets installed
in any scope, and thus the "multi bar" declarations have nothing to hold on
to. What confused me is that the $sub_anon example in my last email works,
I expected it to give the same kind of error! It looks like adding the
"anon" to the proto simply disconnects the proto from the multi, making it
like there was no proto at all.

-y

Reply via email to