Re: Types for Perl 6: request for comments

[email protected] (Brent Laabs)
Newsgroups perl.perl6.language
Message-ID <CAAPDpBwZuJEL+7cFvYO7+2dFfy++QEdR6HwDjEBgZUJg+441bg@mail.gmail.com>
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 <[email protected]> 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;
> }
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.