Skip to content

Commit c8ddd01

Browse files
authored
Update implied separator rule explanation in syntax.rakudoc
Clarify the implied separator rule for lines ending in the closing curly brace of a block or hash literal.
1 parent 2f8a5bd commit c8ddd01

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

doc/Language/syntax.rakudoc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,20 @@ if True {
102102
say "world"
103103
=end code
104104

105-
=head2 Implied separator rule (for statements ending in blocks)
105+
=head2 Implied separator rule
106106

107-
Complete statements ending in bare blocks can omit the trailing
108-
semicolon, if no additional statements on the same line follow the
109-
block's closing curly brace C<}>. This is called the "implied separator
110-
rule." For example, you don't need to write a semicolon after an C<if>
111-
statement block as seen above, and below.
107+
If the last code on a line (excluding an end of line comment) is the
108+
closing curly brace of either a block or a hash constructor literal,
109+
and it can be syntactically validly interpreted as the end of a
110+
statement, then a trailing semicolon is optional (and is typically
111+
omitted).
112+
113+
For example, you don't need to write a semicolon after assigning a
114+
curly braced literal hash to a variable, or after an C<if> statement
115+
block as seen above and below.
112116

113117
=begin code
118+
my $hash = { :foo, :bar }
114119
if True { say "Hello" }
115120
say "world";
116121
=end code
@@ -124,8 +129,9 @@ if True { say "Hello" }; say "world";
124129
=end code
125130

126131
This implied statement separator rule applies in other ways, besides
127-
control statements, that could end with a bare block. For example, in
128-
combination with the colon C<:> syntax for method calls.
132+
control statements, that could end with a bare block or curly brace
133+
hash literal. For example, in combination with the colon C<:> syntax
134+
for method calls.
129135

130136
=begin code
131137
my @names = <Foo Bar Baz>;

0 commit comments

Comments
 (0)