Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more index entries for Signature
  • Loading branch information
gfldex committed Jun 17, 2016
1 parent af3764b commit 8ac1521
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions doc/Type/Signature.pod
Expand Up @@ -115,8 +115,7 @@ sub baz (B<L<Str>>) { "Got passed a Str" }
Type constraints may also be L<type captures|/type/Signature#Type_Captures>.
X<|where>
X<|where clause (Signature)>
In addition to those I<nominal> types, additional constraints can
be placed on parameters in the form of code blocks which must return
a true value to pass the type check
Expand Down Expand Up @@ -226,7 +225,7 @@ be obmitted.
f '10', 10;
# OUTPUT«(Int)(Str)␤»
=head2 X<Slurpy (A.K.A. Variadic) Parameters|parameter,*@;parameter,*%>
=head2 X<Slurpy (A.K.A. Variadic) Parameters|parameter,*@;parameter,*%, slurpy argument (Signature)>
An array or hash parameter can be marked as I<slurpy> by leading asterisk(s),
which means it can bind to an arbitrary amount of arguments (zero or more).
Expand Down Expand Up @@ -314,6 +313,7 @@ the function body.
my &s = f(10, 2, Int.new / Int.new);
say s(2); # 10 / 2 * 2 == 10
X<|positional argument (Signature), named argument (Signature)>
=head2 Positional vs. Named
A parameter can be I<positional> or I<named>. All parameters are positional,
Expand Down Expand Up @@ -365,6 +365,7 @@ The same can be used to convert a Hash into named arguments.
my %pairs = also-named => 4;
f |%pairs; # «(:$also-named)␤»
X<|optional argument (Signature)>
=head2 Optional and Mandatory Parameters
Positional parameters are mandatory by default, and can be made optional
Expand All @@ -374,6 +375,7 @@ with a default value or a trailing question mark:
:($base = 10) # optional parameter, default value 10
:(Int $x?) # optional parameter, default is the Int type object
X<|mandatory named argument (Signature)>
Named parameters are optional by default, and can be made mandatory with a
trailing exclamation mark:
Expand All @@ -387,6 +389,7 @@ notionally) computed anew for each call
:($goal, $accuracy = $goal / 100);
:(:$excludes = ['.', '..']); # a new Array for every call
X<|destructuring arguments (Signature)>
=head2 Destructuring Parameters
Parameters can be followed by a sub-signature in brackets, which will
Expand Down Expand Up @@ -472,11 +475,12 @@ On slurpy parameters, C<is rw> is reserved for future use by language
designers.
The L<C<is raw> trait|/type/Parameter#method_raw> is automatically applied to
parameters declared with a backslash as a "sigil", and may also be used
to make normally sigiled parameters behave like these do. In the special
case of slurpies, which normally produce an C<Array> full of C<Scalar>s
as described above, C<is raw> will instead cause the parameter to produce
a C<List>. Each element of that list will be bound directly as raw parameter.
parameters declared with a L<backslash|/language/variables#Sigilless_variables>
as a "sigil", and may also be used to make normally sigiled parameters behave
like these do. In the special case of slurpies, which normally produce an
C<Array> full of C<Scalar>s as described above, C<is raw> will instead cause
the parameter to produce a C<List>. Each element of that list will be bound
directly as raw parameter.
=head1 Methods
Expand Down

0 comments on commit 8ac1521

Please sign in to comment.