Skip to content

Commit 1bf6eac

Browse files
committed
Rephrasing and reflow
1 parent b66a3c4 commit 1bf6eac

File tree

1 file changed

+71
-61
lines changed

1 file changed

+71
-61
lines changed

doc/Language/operators.pod6

Lines changed: 71 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,13 +2387,13 @@ list:
23872387
say 100, 200 Z+ 42, 23; # OUTPUT: «(142 223)␤»
23882388
say 1..3 Z~ <a b c> Z~ 'x' xx 3; # OUTPUT: «(1ax 2bx 3cx)␤»
23892389
2390+
X<|cross product operator>
23902391
=head2 infix C«X»
23912392
23922393
sub infix:<X>(**@lists --> List:D)
23932394
2394-
Creates a cross product from all the lists, order so that the rightmost
2395-
elements vary most rapidly:X<|cross product operator>
2396-
2395+
Creates a cross product from all the lists, ordered so that the
2396+
rightmost elements vary most rapidly:
23972397
1..3 X <a b c> X 9
23982398
# produces ((1 a 9) (1 b 9) (1 c 9)
23992399
# (2 a 9) (2 b 9) (2 c 9)
@@ -2411,41 +2411,49 @@ X<|...,operators>X<|...^,operators>X<|…,operators>X<|…^,operators>X<|lazy li
24112411
multi sub infix:<...>(**@) is assoc<list>
24122412
multi sub infix:<...^>(**@) is assoc<list>
24132413
2414-
The X<sequence operator>, which can be written either C<...> or as C<> (with variants C<...^> and C<…^>) will produce generic sequences on demand.
2414+
The X<sequence operator>, which can be written either as C<...> or as
2415+
C<> (with variants C<...^> and C<…^>) will produce (possibly lazy)
2416+
generic sequences on demand.
24152417
2416-
The left-hand side will always include initial elements; it may
2418+
The left-hand side will always include the initial elements; it may
24172419
include a generator too. The right-hand side will have an endpoint,
2418-
which can be C<Inf> or C<*> for "infinite" lists (whose elements are
2419-
only produced on demand), an expression which will end the sequence
2420-
when C<True>, or other elements such as L<Junctions|/type/Junctions>.
2420+
which can be C<Inf> or C<*> for "infinite" lists (that is, I<lazy> lists
2421+
whose elements are only produced on demand), an expression which will
2422+
end the sequence when C<True>, or other elements such as
2423+
L<Junctions|/type/Junctions>.
24212424
24222425
The sequence operator invokes the generator with as many arguments as
24232426
necessary. The arguments are taken from the initial elements and the
2424-
already generated elements. The default generator is C<*.>L<succ|/type/succ> or
2425-
C<*.>L<pred|/type/pred>, depending on how the end points compare:
2427+
already generated elements. The default generator is
2428+
C<*.>L<succ|/type/succ> or C<*.>L<pred|/type/pred>, depending on how the
2429+
end points compare:
24262430
24272431
say 1 ... 4; # OUTPUT: «(1 2 3 4)␤»
24282432
say 4 ... 1; # OUTPUT: «(4 3 2 1)␤»
24292433
say 'a' ... 'e'; # OUTPUT: «(a b c d e)␤»
24302434
say 'e' ... 'a'; # OUTPUT: «(e d c b a)␤»
24312435
2432-
An endpoint of C<*> (L<Whatever|/type/Whatever>), C<Inf> or C<> generates on demand an infinite sequence,
2433-
with a default generator of *.succ
2436+
An endpoint of C<*> (L<Whatever|/type/Whatever>), C<Inf> or C<>
2437+
generates on demand an infinite sequence, with a default generator of
2438+
C<*.succ>
24342439
24352440
say (1 ... *)[^5]; # OUTPUT: «(1 2 3 4 5)␤»
24362441
2437-
Custom generators need to be the last element of the list before the '...' operator.
2438-
This one takes two arguments, and generates the Fibonacci numbers
2442+
Custom generators need to be the last element of the list before the
2443+
'...' operator. This one takes two arguments, and generates the
2444+
eight first Fibonacci numbers
24392445
2440-
say (1, 1, -> $a, $b { $a + $b } ... *)[^8]; # OUTPUT: «(1 1 2 3 5 8 13 21)␤»
2441-
# same but shorter
2442-
say (1, 1, * + * ... *)[^8]; # OUTPUT: «(1 1 2 3 5 8 13 21)␤»
2446+
=for code
2447+
say (1, 1, -> $a, $b { $a + $b } ... *)[^8]; # OUTPUT: «(1 1 2 3 5 8 13 21)␤»
2448+
# same but shorter
2449+
say (1, 1, * + * ... *)[^8]; # OUTPUT: «(1 1 2 3 5 8 13 21)␤»
24432450
24442451
Of course the generator can also take only one argument.
24452452
2446-
say 5, { $_ * 2 } ... 40; # OUTPUT: «5 10 20 40␤»
2453+
say 5, { $_ * 2 } ... 40; # OUTPUT: «5 10 20 40␤»
24472454
2448-
There must be at least as many initial elements as arguments to the generator.
2455+
There must be at least as many initial elements as arguments to the
2456+
generator.
24492457
24502458
Without a generator and with more than one initial element and all initial
24512459
elements numeric, the sequence operator tries to deduce the generator. It
@@ -2463,7 +2471,7 @@ This allows you to write
24632471
24642472
say 1, 1, * + * ...^ *>= 100;
24652473
2466-
To generate all Fibonacci numbers up to but excluding 100.
2474+
to generate all Fibonacci numbers up to but excluding 100.
24672475
24682476
The C<...> operators consider the initial values as "generated elements" as
24692477
well, so they are also checked against the endpoint:
@@ -2475,18 +2483,20 @@ well, so they are also checked against the endpoint:
24752483
=head1 List prefix precedence
24762484
24772485
X<|list =>
2486+
X<List assignment operator>.
24782487
=head2 infix C«=»
24792488
2480-
X<List assignment operator>. Its exact semantics are left to the container type
2481-
on the left-hand side. See L<Array|/type/Array> and L<Hash|/type/Hash> for common cases.
2489+
In this context, it acts as the list assignment operator. Its exact
2490+
semantics are left to the container type on the left-hand side. See
2491+
L<Array|/type/Array> and L<Hash|/type/Hash> for common cases.
24822492
2483-
The distinction between item assignment and list assignment is determined by
2484-
the parser depending on the syntax of the left-hand side.
2493+
The distinction between item assignment and list assignment is
2494+
determined by the parser depending on the syntax of the left-hand side.
24852495
24862496
=head2 infix C«:=»
24872497
2488-
X<Binding operator>. Whereas C<$x = $y> puts the value in C<$y> into C<$x>, C<$x :=
2489-
$y> makes C<$x> and C<$y> the same thing.
2498+
X<Binding operator>. Whereas C<$x = $y> puts the value in C<$y> into
2499+
C<$x>, C<$x := $y> makes C<$x> and C<$y> the same thing.
24902500
24912501
my $a = 42;
24922502
my $b = $a;
@@ -2505,10 +2515,11 @@ different.
25052515
This will output 43, since C<$b> and C<$a> both represented the same
25062516
object.
25072517
2508-
If type constrains on variables or containers are present a type check will be
2509-
performed at runtime. On failure C<X::TypeCheck::BindingType> will be thrown.
2518+
If type constrains on variables or containers are present a type check
2519+
will be performed at runtime. On failure C<X::TypeCheck::BindingType>
2520+
will be thrown.
25102521
2511-
Please note that C<:=> is a compile time construct. As such it can not
2522+
Please note that C<:=> is a compile time operator. As such it can not
25122523
be referred to at runtime and thus can't be used as an argument to
25132524
metaoperators.
25142525
@@ -2517,40 +2528,37 @@ metaoperators.
25172528
X<Read-only binding operator>, not yet implemented in Rakudo.
25182529
See L<C<infix :=>|:=>.
25192530
2531+
X<|stub operator>
25202532
=head2 listop C«...»
25212533
2522-
X<|stub operator>
2523-
The I<yada, yada, yada> operator or I<stub> operator. If it's the only
2524-
statement in a routine or type, it marks that routine or type as a stub
2525-
(which is significant in the context of pre-declaring types and composing
2526-
roles).
2534+
Called the I<yada, yada, yada> operator or I<stub> operator, if it's the
2535+
only statement in a routine or type, it marks that routine or type as a
2536+
stub (which is significant in the context of pre-declaring types and
2537+
composing roles).
25272538
2528-
If the C<...> statement is executed, it calls L<fail|/routine/fail>, with the default
2529-
message C<stub code executed>.
2539+
If the C<...> statement is executed, it calls L<fail|/routine/fail>,
2540+
with the default message C<Stub code executed>.
25302541
2542+
X<Fatal stub operator>.
25312543
=head2 listop C«!!!»
25322544
2533-
X<Fatal stub operator>.
2545+
If it's the only statement in a routine or type, it marks that routine
2546+
or type as a stub (which is significant in the context of pre-declaring
2547+
types and composing roles).
25342548
2535-
If it's the only
2536-
statement in a routine or type, it marks that routine or type as a stub
2537-
(which is significant in the context of pre-declaring types and composing
2538-
roles).
2549+
If the C<!!!> statement is executed, it calls L<die|/routine/die>, with
2550+
the default message C<Stub code executed>.
25392551
2540-
If the C<!!!> statement is executed, it calls L<die|/routine/die>, with the default
2541-
message C<stub code executed>.
2542-
2543-
=head2 listop C«???»
25442552
25452553
X<Admonitory stub operator>.
2554+
=head2 listop C«???»
25462555
2547-
If it's the only
2548-
statement in a routine or type, it marks that routine or type as a stub
2549-
(which is significant in the context of pre-declaring types and composing
2550-
roles).
2556+
If it's the only statement in a routine or type, it marks that routine
2557+
or type as a stub (which is significant in the context of pre-declaring
2558+
types and composing roles).
25512559
2552-
If the C<???> statement is executed, it calls L<warn|/routine/warn>, with the default
2553-
message C<stub code executed>.
2560+
If the C<???> statement is executed, it calls L<warn|/routine/warn>,
2561+
with the default message C<Stub code executed>.
25542562
25552563
=head2 Reduction operators
25562564
@@ -2562,7 +2570,8 @@ that reduces using that operation.
25622570
my @a = (5, 6);
25632571
say [*] @a; # 5 * 6 = 30
25642572
2565-
Reduction operators have the same associativity as the operators they are based on.
2573+
Reduction operators have the same associativity as the operators they
2574+
are based on.
25662575
25672576
say [-] 4, 3, 2; # 4-3-2 = (4-3)-2 = -1
25682577
say [**] 4, 3, 2; # 4**3**2 = 4**(3**2) = 262144
@@ -2574,19 +2583,20 @@ Reduction operators have the same associativity as the operators they are based
25742583
Same as L<infix &&|/language/operators#infix_%26%26>, except with looser
25752584
precedence.
25762585
2577-
Short-circuits so that it returns the first operand that evaluates to C<False>, otherwise
2578-
returns the last operand. Note that C<and> is easy
2586+
Short-circuits so that it returns the first operand that evaluates to
2587+
C<False>, otherwise returns the last operand. Note that C<and> is easy
25792588
to misuse. See L<traps|/language/traps#Loose_boolean_operators>.
25802589
25812590
=head2 infix C«andthen» X<|andthen>
25822591
2583-
The C<andthen> operator returns L«C<Empty>|/type/Slip#index-entry-Empty-Empty» upon encountering
2584-
the first L<undefined|/routine/defined> argument, otherwise the last argument.
2585-
Last argument
2586-
is returned as-is, without being checked for definedness at all.
2587-
Short-circuits. The result of the left side is bound to C<$_> for the
2588-
right side, or passed as arguments if the right side is a
2589-
L«C<Callable>|/type/Callable», whose L<count|/type/count> must be C<0> or C<1>.
2592+
The C<andthen> operator returns
2593+
L«C<Empty>|/type/Slip#index-entry-Empty-Empty» upon encountering the
2594+
first L<undefined|/routine/defined> argument, otherwise the last
2595+
argument. Last argument is returned as-is, without being checked for
2596+
definedness at all. Short-circuits. The result of the left side is bound
2597+
to C<$_> for the right side, or passed as arguments if the right side is
2598+
a L«C<Callable>|/type/Callable», whose L<count|/type/count> must be C<0>
2599+
or C<1>.
25902600
25912601
A handy use of this operator is to alias a routine's return value to C<$_> and
25922602
to do additional manipulation with it, such as printing or returning it to

0 commit comments

Comments
 (0)