diff --git a/doc/Type/Signature.pod6 b/doc/Type/Signature.pod6 index 4dd36c75f..7436813c9 100644 --- a/doc/Type/Signature.pod6 +++ b/doc/Type/Signature.pod6 @@ -276,16 +276,24 @@ The L document further elaborates on the concepts of instances and type objects and discovering them with the C<.DEFINITE> method. -=head3 X«Constraining signatures of Callables|function reference (constrain)» +=head3 X«Constraining signatures of Callables|Callable (constrain)» -To constrain L and L references based -on their signature write the signature after the argument name. +A L parameter can be constrained by its signature, by specifying +a L literal right after the parameter (no whitespace allowed): sub f(&c:(Int, Str)) { say c(10, 'ten') }; sub g(Int $i, Str $s) { $s ~ $i }; f(&g); # OUTPUT: «ten10␤» +This shorthand syntax is available only for parameters with the `&` sigil. For +others, you need to use the long version: + + sub f($c: where .signature ~~ :(Int, Str)) { say $c(10, 'ten') }; + sub g(Num $i, Str $s) { $s ~ $i }; + f(&g); + # OUTPUT: «ten10␤» + =head3 X«Constraining Return Types|-->;returns» There are multiple ways to constrain return types on a sub or method. All versions below