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 itself!), so
that first line is redundant but good practice.

On Sat, Jun 27, 2015 at 5:26 PM, yary <not....@gmail.com> wrote:

> These two variations on Brent's work the same as the original- what subtle
> differences happen by adding "anon" or "my" to the declarations?
>
> my $sub_anon = do {
>     anon proto foo (|) { * }
>     multi foo (Int $x) { $x + 1 }
>     multi foo (Str $y) { $y ~ 'a' }
>
>     &foo;
> }
>
> my $sub_my = do {
>     my proto foo (|) { * }
>     my multi foo (Int $x) { $x + 1 }
>     my multi foo (Str $y) { $y ~ 'a' }
>
>     &foo;
> }
>

Reply via email to