@@ -60,6 +60,8 @@ syntactic flexibility against the goal of having a consistent,
60
60
deterministic, extensible grammar that supports single-pass parsing and
61
61
helpful error messages, integrates features like custom operators cleanly,
62
62
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.
63
65
64
66
As a result, there are various places in the syntax where whitespace is
65
67
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.>
74
76
substr ($s, 4, 1); # Perl 5 (in Perl 6 this would try to pass a single
75
77
# argument of type List to substr)
76
78
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
+
78
81
= end item
79
82
80
83
= 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. >
82
85
83
86
$people [0] -> name; # Perl 5
84
87
@people[0].name # Perl 6
88
+ @people.[0].name # Perl 6, alternative pseudo-method style
89
+
85
90
= end item
86
91
87
92
= 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. >
90
94
91
95
$i ++; # Perl 5
92
96
$i++; # Perl 6
97
+ $i.++; # Perl 6, alternative pseudo-method style
98
+
93
99
= end item
94
100
95
101
= 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. >
98
104
99
105
$n<1; # Perl 5 (in Perl 6 this would conflict with postcircumfix < >)
100
106
$n < 1; # Perl 6
107
+
101
108
= end item
102
109
103
110
However, note that you can use L < unspace|http://design.perl6.org/S02.html#Unspaces >
104
111
to add whitespace in Perl 6 code in places where it is otherwise not
105
112
allowed:
106
113
107
114
# Perl 5
108
- my @books = $xml->parse_file($file) # some comment
115
+ my @books = $xml->parse_file($file) # some comment
109
116
->findnodes("/library/book");
110
117
111
118
# Perl 6
0 commit comments