On Fri, Jun 26, 2015 at 4:32 AM, Giuseppe Castagna
g...@pps.univ-paris-diderot.fr wrote:
my $sub = do {
proto foo (|) { * }
multi foo (Int $x) { $x + 1 }
multi foo (Str $y) { $y ~ 'a' }
foo;
}
Oh yes, nice ... I think I will add it in my paper (and if you send me
On 24/06/15 21:27, yary wrote:
I'm reading it a bit at a time on lunch break, thanks for sending it
along, it's educational.
My comments here are all about the example on the top of page 5,
starting with the minutest. First a typo, it says subC where it
should say sumC
multi sub sumB is
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
Subs are lexical by default, so adding my to the function declarators does
nothing.
Not sure what anon is doing there. My guess is that anon in sink context
does nothing, and Rakudo just builds another proto for foo when it sees the
first multi. Protos are optional (but not in the compiler