String
Unlike most languages that hardwire their quoting mechanisms, the quote mechanism in Raku is extensible, and all normal-looking quotes actually derive from a parent quoting language called Q via grammatical mixins, applied via standard Raku adverbial syntax. The available quote mixins, straight from current spec S02, are:
In any case, an initial Q
, q
, or qq
may omit the initial colon to form traditional Perl quotes such as qw//
.
And Q can be used by itself to introduce a quote that has no escapes at all except for the closing delimiter:
Note that the single quotes there imply no single quoting semantics as they would in Perl 5. They're just the quotes the programmer happened to choose, since they were most like the raw quoting. Single quotes imply :q
only when used as normal single quotes are, as discussed below.
As in Perl 5, you can use any non-alphanumeric, non-whitespace characters for delimiters with the general forms of quoting, including matching bracket characters, including any Unicode brackets.
Using the definitions above, we can derive the various standard "sugar" quotes from Q, including:
The :qq
-derived languages all give normal Perlish interpolation, but individual interpolations may be chosen or suppressed with extra adverbs.
Unlike in Perl 5, we don't use backticks as shorthand for what is now expressed as qqx//
in Raku.
(Backticks are now reserved for user-defined syntax.)
Heredocs now have no special <<
syntax, but fall out of the :to
adverb:
Indentation equivalent to the ending tag is automatically removed.
Backslash sequences recognized by :b
(and hence :qq
) include:
Leading 0
specifically does not mean octal in Perl 6; you must use \o
instead.
Last updated