Skip to content

Commit 9256c86

Browse files
committed
doc [&sub-name] form for meta ops
1 parent 4932a10 commit 9256c86

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doc/Language/operators.pod

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ L<Defining Operators functions|/language/functions#Defining_Operators>.
109109
110110
=head1 Meta Operators
111111
112-
Meta operators can be parameterized with other operators in the same way as
113-
functions can take functions as parameters. Perl 6 will generate the actual
114-
combined operator in the background, allowing the mechanism to be applied
115-
to user defined operators. There are quite a few Meta operators with
116-
different semantics, as explained in detail as follows.
112+
Meta operators can be parameterized with other operators or subroutines in the
113+
same way as functions can take functions as parameters. To use a subroutine as
114+
a parameter prefix it's name with a C<&>. Perl 6 will generate the actual
115+
combined operator in the background, allowing the mechanism to be applied to
116+
user defined operators. There are quite a few Meta operators with different
117+
semantics, as explained in detail as follows.
117118
118119
=head1 Substitution Operators
119120
@@ -298,6 +299,8 @@ Reduction operators apply any infix operator, surrounded by C<[> and C<]>,
298299
element by element and return the resulting value.
299300
300301
say [+] 1, 2, 3; # 6
302+
sub plus { $^a + $^b };
303+
say [&plus] 1, 2, 3; # 6
301304
302305
They can be defined as a list prefix operators or will be generated automatically.
303306

0 commit comments

Comments
 (0)