Skip to content

Commit cd2216f

Browse files
committed
Distinguish between qqww and « » quoting
The "Word quoting with interpolation and quote protection" section previously stated that qqww and « » are equivalent. Changing that to indicate that, while very similar, « » will create allomorphs while qqww will not by default.
1 parent 28599bd commit cd2216f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

doc/Language/quoting.pod6

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ Note that variable interpolation happens before word splitting:
310310
my @list = qqw{$a c};
311311
.say for @list; # OUTPUT: «a␤b␤c␤»
312312
313-
=head2 X<<<Word quoting with interpolation and quote protection: qqww|quote,qqww;quote,<< >>;quote,« »>>>
313+
=head2 X<<<Word quoting with interpolation and quote protection: qqww|quote,qqww;>>>
314314
315315
The C<qqw> form of word quoting will treat quote characters literally, leaving them in the
316316
resulting words:
@@ -322,11 +322,6 @@ you need to use the C<qqww> variant:
322322
323323
my $a = 42; say qqww{"$a b" c}.perl; # OUTPUT: «("42 b", "c")␤»
324324
325-
or equivalently:
326-
327-
my $a = 42; say <<"$a b" c>>.perl; # OUTPUT: «("42 b", "c")␤»
328-
my $a = 42; say «"$a b" c».perl; # OUTPUT: «("42 b", "c")␤»
329-
330325
Quote protection happens before interpolation, and interpolation happens before word splitting,
331326
so quotes coming from inside interpolated variables are just literal quote characters:
332327
@@ -335,6 +330,20 @@ so quotes coming from inside interpolated variables are just literal quote chara
335330
my $b = "1 \"2 3\"";
336331
say qqww{"$b" $b}.perl; # OUTPUT: «("1 \"2 3\"", "1", "\"2", "3\"")␤»
337332
333+
=head2 X<<<Word quoting with interpolation and quote protection: « »|quote,<< >>;quote,« »>>>
334+
335+
This style of quoting is like C<qqww>, but with an extra feature that lets you construct
336+
L<allomorphs|/language/glossary#index-entry-Allomorph>. The ASCII equivalent to C<« »> are
337+
double angle brackets C«<< >>».
338+
339+
# Allomorph Construction
340+
my $a = 42; say « $a b c ».perl; # OUTPUT: «(IntStr.new(42, "42"), "b", "c")␤»
341+
my $a = 42; say << $a b c >>.perl; # OUTPUT: «(IntStr.new(42, "42"), "b", "c")␤»
342+
343+
# Quote Protection
344+
my $a = 42; say « "$a b" c ».perl; # OUTPUT: «("42 b", "c")␤»
345+
my $a = 42; say << "$a b" c >>.perl; # OUTPUT: «("42 b", "c")␤»
346+
338347
=head2 X<Shell quoting: qx|quote,qx>
339348
340349
To run a string as an external program, not only is it possible to pass the

0 commit comments

Comments
 (0)