There is no need for a question mark after the $limit parameter, since
supplying a default value for a parameter is sufficient to make this
parameter optional.



Le dim. 30 sept. 2018 à 11:17, ToddAndMargo <toddandma...@zoho.com> a
écrit :

> On 9/30/18 1:21 AM, JJ Merelo wrote:
> >
> >
> > El dom., 30 sept. 2018 a las 10:15, Laurent Rosenfeld via perl6-users
> > (<perl6-us...@perl.org <mailto:perl6-us...@perl.org>>) escribió:
> >
> >     the words method is extracting items from an input string. The
> >     $limit parameter tells the words method to extract not more than
> >     $limit items from the string. Setting the default to Inf only tells
> >     the  method to extract as many items as it can from the input (i.e.
> >     to process the whole string), without any limit. But since the input
> >     string cannot be infinite, the number of items will also not be
> >     infinite. So, the Inf default for $limit just states that there is
> >     no limit, but you'll never get an infinity of items from a
> >     non-infinite string.
> >
> >
> > There's no Inf default now in the definition (after latest code
> > changes), and it's been changed in the documentation accordingly. It's
> > left in the examples, however (since that "default" is in the code too,
> > and is tested in roast), but that can be eliminated if it leads to
> > confusion.
> >
> > Cheers
> >
> > JJ
>
>
> Hi JJ,
>
> I am confused.  I thought that
>
>       $limit = Inf
> used in
>
>       multi method words(Str:D $input: $limit = Inf --> Seq)
> meant that the default was "Inf"
>
> Also, it is not stated that $limit is optional.  I would
> propose adding a "?" to the end of $limit:
>
>       multi method words(Str:D $input : $limit? = Inf --> Seq)
>
> This would keep with the subroutine rules for the declarations
> of optional variables.
>
> -T
>

Reply via email to