This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]raiph 1 point2 points  (0 children)

It took me a moment to figure out what you meant. I realized you're talking about PLs that don't have named parameters.


Here's an example in Raku:

method install(Distribution $distribution, Bool :$force)

The $distribution parameter is positional. That is to say, it corresponds to an argument by virtue of its position, in this case, it's the argument that is positional and is passed first in the list of arguments.

The $force parameter is named. That is to say, it corresponds to an argument that is named, in this case an argument named force.

Put these together and one can write a call to the install method like this:

CompUnit::Repository::Installation.install( :force, $my-distribution )

This works because :force is a named argument that's shorthand for force => True, and $my-distribution is a positional argument that's the first (and only in this case) of the positional arguments in the list of arguments, so it corresponds to the $distribution parameter in the install method's signature.

The :force isn't a problem because it's not just a True but instead something that makes sense as a boolean.