Skip to content

Commit c6babf0

Browse files
committed
some clarifications on whitespace requirements
1 parent 1e44bb2 commit c6babf0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lib/Language/5to6.pod

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ syntactic flexibility against the goal of having a consistent,
6060
deterministic, extensible grammar that supports single-pass parsing and
6161
helpful error messages, integrates features like custom operators cleanly,
6262
and doesn't lead programmers to accidentally misstate their intent.
63+
Also, the practice of "code golf" is slightly de-emphasized; Perl 6 is
64+
designed to be more concise in concepts than in keystrokes.
6365
6466
As a result, there are various places in the syntax where whitespace is
6567
optional in Perl 5, but is either mandatory or forbidden in Perl 6. Many of
@@ -74,38 +76,43 @@ I<No space allowed before the opening parenthesis of an argument list.>
7476
substr ($s, 4, 1); # Perl 5 (in Perl 6 this would try to pass a single
7577
# argument of type List to substr)
7678
substr($s, 4, 1); # Perl 6
77-
substr $s, 4, 1; # Perl 6 - alternative, parentheses-less style
79+
substr $s, 4, 1; # Perl 6 - alternative parentheses-less style
80+
7881
=end item
7982
8083
=begin item
81-
I<No space allowed before the opening bracket of an array/hash subscript, or around the method call operator.>
84+
I<No space allowed before the opening bracket of a postcircumfix (such as an array/hash subscript), or around the method call operator.>
8285
8386
$people [0] -> name; # Perl 5
8487
@people[0].name # Perl 6
88+
@people.[0].name # Perl 6, alternative pseudo-method style
89+
8590
=end item
8691
8792
=begin item
88-
I<No space allowed after a prefix (or before a postfix/postcircumfix)
89-
operator.>
93+
I<No space allowed before a postfix operator.>
9094
9195
$i ++; # Perl 5
9296
$i++; # Perl 6
97+
$i.++; # Perl 6, alternative pseudo-method style
98+
9399
=end item
94100
95101
=begin item
96-
I<Space required after (before) an infix operator, if it would otherwise
97-
conflict with an existing prefix (postfix/postcircumfix) operator.>
102+
I<Space required before an infix operator if it would
103+
conflict with an existing postfix/postcircumfix operator.>
98104
99105
$n<1; # Perl 5 (in Perl 6 this would conflict with postcircumfix < >)
100106
$n < 1; # Perl 6
107+
101108
=end item
102109
103110
However, note that you can use L<unspace|http://design.perl6.org/S02.html#Unspaces>
104111
to add whitespace in Perl 6 code in places where it is otherwise not
105112
allowed:
106113
107114
# Perl 5
108-
my @books = $xml->parse_file($file) # some comment
115+
my @books = $xml->parse_file($file) # some comment
109116
->findnodes("/library/book");
110117
111118
# Perl 6

0 commit comments

Comments
 (0)