Hacker News new | ask | show | jobs
by b2gills 2311 days ago
Those work in Raku, with the exception of ‟at least two styles”.

    .say for q[‟”].uninames
    # DOUBLE HIGH-REVERSED-9 QUOTATION MARK
    # RIGHT DOUBLE QUOTATION MARK
If you use one type of quote, you can use the others inside of it with no problem.

    “double "quotes"”
(Raku doesn't use a tokenizer.)

Also note that you can use a variety of characters for quoting if you use `q`, `qq` or `Q` etc.

    q<<<<1 < 2>>>>  eq  '1 < 2'  eq  q^1 < 2^  eq  q%1 < 2%  eq  q「1 < 2」
Note that many Unicode characters which have a LEFT and RIGHT variant will also be paired when you do that. q⦑like this⦒

In Raku string literals are actually a [parameterized domain specific language](https://docs.raku.org/language/quoting). (The domain of creating strings.)

    my $buffer = Blob.new(115,116,114,105,110,103); # 'string'.encode()

    Q            # start with raw quoting
    :scalar      # enable embedding the value of scalars
    :backslash   # enable backslashing characters
    [This is a $buffer.decode()\n]
There are shortcuts for common uses

    'single'  eq  q [single]  eq  Q :single [single]  eq  Q :q [single]
    ‘single’  eq  ‚single’

    "double"  eq  qq [double]  eq  Q :double [double]  eq  Q :qq [double]
    “double”  eq  „double”

    「raw」   eq   Q [raw]

    < words >   eqv   qw [ words ]   eqv   q :words [ words ]

    << quote words >>   eqv   qqww [ quote words ]   eqv   Q :double :quotewords [ quote words ]
    « quote words »
This is not exhaustive.

:double is actually short for :scalar :array :hash :function :closure :backslash

:words splits on whitespace :quotewords splits on whitespace but respects quoted sections

    q      :words [ a "b c" ]   eqv   ( 'a', '"b', 'c"' )
    q :quotewords [ a "b c" ]   eqv   ( 'a', 'b c' )
Note that :double is the same as any adverb in the language, so you can negate a feature with :!double.

    qq [with newline\n]
    qq :!backslash [without newline\n]

    qq :!array [user@example.com()]
(It's actually rather difficult to accidently use @ or % variables.)