Skip to content

Commit

Permalink
Document bare :D at al in parameter lists
Browse files Browse the repository at this point in the history
wording improvements are very welcome.
Also, I did not find a proper section to document this,
so I made my own. Suggestions for a better place are
also very welcome.
  • Loading branch information
moritz committed Feb 27, 2015
1 parent 582cee8 commit ab16f15
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion S06-routines.pod
Expand Up @@ -10,7 +10,7 @@ Synopsis 6: Subroutines
Created: 21 Mar 2003

Last Modified: 27 Feb 2015
Version: 165
Version: 166

This document summarizes Apocalypse 6, which covers subroutines and the
new type system.
Expand Down Expand Up @@ -932,6 +932,26 @@ or function dispatch based on whether the supplied C<Capture>'s first
argument is marked as an invocant. For ordinary calls this can
always be determined at compile time, however.

=head2 Parameters with type constraints

Parameters can be constraint to other types than the default simply by
using the type name in from of the parameter:

sub double(Numeric $x) { 2 * $x }

If no explicit type constraint is given, it defaults to the type of the
surrounding package for method invocants, and to C<Any> everywhere else.

A bare C<:D>, C<:U>, C<:T> or C<:_> instead of a type constraint limits the
default type to definite, undefined, type objects or any object. The default
still applies, so in

class Con {
method man(:U: :D $x)
}

the signature is equivalent to C<(Con:U: Any:D $x)>.

=head2 Longname parameters

A routine marked with C<multi> can mark part of its parameters to
Expand Down

0 comments on commit ab16f15

Please sign in to comment.