@@ -317,7 +317,7 @@ If instead we had declared C<dice> as a regular
317
317
C < dice(+(dice())) > , resulting in an error since C < sub dice > expects zero
318
318
arguments.
319
319
320
- = head1 Statements and Expressions
320
+ = head1 Statements and expressions
321
321
322
322
Perl 6 programs are made of lists of statements. A special case of a statement
323
323
is an I < expression > , which returns a value. For example C < if True { say 42 } >
@@ -340,10 +340,10 @@ C<$x>.
340
340
341
341
= head1 Terms
342
342
343
- Terms are the basic nouns that, optionally together with operators, can form
344
- expressions. Examples for terms are variables (C < $x > ), barewords such as type
345
- names (C < Int > ), literals (C < 42 > ), declarations (C < sub f() { } > ) and calls
346
- (C < f() > ).
343
+ Terms are the basic nouns that, optionally together with operators, can
344
+ form expressions. Examples for terms are variables (C < $x > ), barewords
345
+ such as type names (C < Int > ), literals (C < 42 > ), declarations (C < sub f() { } > )
346
+ and calls (C < f() > ).
347
347
348
348
For example, in the expression C < 2 * $salary > , C < 2 > and C < $salary > are two
349
349
terms (an L < integer|/type/Int > literal and a L < variable|/language/variables > ).
@@ -362,7 +362,7 @@ them.
362
362
See the L < documentation on variables|/language/variables > for more details.
363
363
364
364
365
- = head2 Barewords (Constants, Type Names )
365
+ = head2 Barewords (constants, type names )
366
366
367
367
Pre-declared identifiers can be terms on their own. Those are typically type
368
368
names or constants, but also the term C < self > which refers to an object that
@@ -386,7 +386,7 @@ variables:
386
386
# ^^^ type name
387
387
388
388
389
- = head2 Packages and Qualified Names
389
+ = head2 Packages and qualified names
390
390
391
391
Named entities, such as variables, constants, classes, modules or subs,
392
392
are part of a namespace. Nested parts of a name use C < :: > to separate
@@ -639,10 +639,11 @@ You can also assign subroutines to variables.
639
639
my &f = -> { say "Hello!" } # Lambda style syntax. The & sigil indicates the variable holds a function
640
640
my $f = -> { say "Hello!" } # Functions can also be put into scalars
641
641
642
- = head3 X < Package, Module, Class, Role, and Grammar declaration|declarator,unit;declarator,module;declarator,package >
642
+ = head3 X < C < Package > , C < Module > , C < Class > , C < Role > , and C < Grammar > declaration|declarator,unit;declarator,module;declarator,package>
643
643
644
- There are several types of package, each declared with a keyword, a name, some optional traits, and a
645
- body of subroutines, methods, or rules.
644
+ There are several types of package, each declared with a keyword, a
645
+ name, some optional traits, and a body of subroutines, methods, or
646
+ rules.
646
647
647
648
package P { }
648
649
@@ -654,9 +655,10 @@ body of subroutines, methods, or rules.
654
655
655
656
grammar G { }
656
657
657
- You can declare a C < unit > package without explicit curly brackets. This must be at the start of the
658
- file (preceded only by comments or C < use > statements), and the rest of the file will be taken as
659
- being the body of the package.
658
+ You can declare a C < unit > package without explicit curly brackets. This
659
+ must be at the start of the file (preceded only by comments or C < use >
660
+ statements), and the rest of the file will be taken as being the body of
661
+ the package.
660
662
661
663
= begin code :skip-test
662
664
unit module M;
@@ -703,16 +705,16 @@ are subroutines invoked against an object (i.e., a class instance).
703
705
Within a method the special variable C < self > contains the object instance
704
706
(see L < Methods|/language/classtut#Methods > ).
705
707
706
- = begin code :skip-test
707
- # Method invocation. Object (instance) is $person, method is set-name-age
708
- $person.set-name-age('jane', 98); # Most common way
709
- $person.set-name-age: 'jane', 98; # Precedence drop
710
- set-name-age($person: 'jane', 98); # Invocant marker
711
- = end code
708
+ = begin code :skip-test
709
+ # Method invocation. Object (instance) is $person, method is set-name-age
710
+ $person.set-name-age('jane', 98); # Most common way
711
+ $person.set-name-age: 'jane', 98; # Precedence drop
712
+ set-name-age($person: 'jane', 98); # Invocant marker
713
+ = end code
712
714
713
715
For more information see L < functions|/language/functions > .
714
716
715
- = head2 Precedence Drop
717
+ = head2 Precedence drop
716
718
717
719
In the case of method invocation (i.e., when invoking a subroutine against
718
720
a class instance) it is possible to apply the C < precedence drop > , identified
@@ -728,9 +730,9 @@ method calls):
728
730
say $band.substr: 0, 3 .substr( 0, 1 ); # Foo
729
731
= end code
730
732
731
- In the second method call the rightmost C < substr > is applied to "3" and not
732
- to the result of the leftmost C < substr > , which on the other hand yields precedence
733
- to the rightmost one.
733
+ In the second method call the rightmost C < substr > is applied to "3" and
734
+ not to the result of the leftmost C < substr > , which on the other hand
735
+ yields precedence to the rightmost one.
734
736
735
737
= head1 Operators
736
738
@@ -750,11 +752,11 @@ There are five types (arrangements) for operators, each taking either one or two
750
752
%foo<bar> # postcircumfix, operator comes after first input and surrounds second
751
753
= end code
752
754
753
- = head2 Meta Operators
755
+ = head2 Metaoperators
754
756
755
- Operators can be composed. A common example of this is combining an infix
756
- (binary) operator with assignment. You can combine assignment with any binary
757
- operator.
757
+ Operators can be composed. A common example of this is combining an
758
+ infix (binary) operator with assignment. You can combine assignment with
759
+ any binary operator.
758
760
759
761
= begin code :skip-test
760
762
$x += 5 # Adds 5 to $x, same as $x = $x + 5
0 commit comments