On 06/21/2017 11:03 PM, Brandon Allbery wrote:

On Thu, Jun 22, 2017 at 1:51 AM, Todd Chester <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:

        You want named parameters.

             sub MAIN(:$fixed-string, :$extended-regex, ...) {
               # $fixed-string and $extended-regex are Bools here,
               # True if the corresponding option specified
             }

        You should recognize this as being similar to named parameters
        work for
        normal Perl 6 functions, but MAIN exposes them to the command
        line like
        GNUish long options.


    What does the ":" do?  and does it give you back the
    value associated with it, if there is one?


I guess that means you did not recognize colon-pair syntax for named parameters.

https://docs.perl6.org/language/terms#Pair see at the end for their use as named parameters.

Since I assume I'm going to have to read that link for someone on the list anyway:

:name(value)
:name<value>
:name
:!name
:$name

are all colon-pairs. When used as parameters, they indicate named (as opposed to positional) parameters.

The first form allows you to associate any variable name with the parameter name, optionally with a type. The second form is always a String (and any of the bracketing String forms can be used, e.g. :foo<<bar>> --- but *not* :foo"bar"; that would need to use the first form). The final three are always Bools; the last one takes the parameter name from the variable name.


Thank you!

I have some reading/learning to do.

Reply via email to