What does the plus in the method declaration in perl6 mean?

What does plus mean in method declarations in Perl6?

Here is an example from spec

submethod BUILD (+$tail, +@legs , *%extraargs) { $.tail = $tail; @:legs = @legs; } 
+4
source share
2 answers

About a week ago (September 2015), Larry Wall introduced the new + prefix, one of four parameter prefixes ( * , ** , + , | ), which mean sloppy (variable) parameters . So far, he has added this new prefix to the Rakudo Perl 6 compiler, added several tests, given a brief unofficial description of it in # perl6, and added a section on it to the corresponding language document.


The example given in the original question is taken from the archive of an unofficial document written and frozen in time ten years ago. At that time, the + parameter prefix meant a named parameter, as opposed to a positional one . Currently we use for this : thus:

 submethod BUILD (:$tail, :@legs, *%extraargs) { $.tail = $tail; @.legs = @legs; } 
+7
source

Your "spec" references are related to a historical document, and the syntax has long gone with Perl 6. I'm not sure if it used perhaps "at least one argument", similar to the + quantifier in regular expressions.

For the latest specs, please read the http://perlcabal.org/syn/S06.html , which contains all the information about signatures and routines.

+7
source

All Articles