Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Small Perl 6 discoveries IV, hash access

by Laurent_R (Canon)
on Oct 07, 2017 at 21:21 UTC ( [id://1200917]=note: print w/replies, xml ) Need Help??


in reply to Re: Small Perl 6 discoveries IV, hash access
in thread [Perl6] Perl 6 discoveries IV, hash access

There's no mention explicitly that <> does not interpolate, unless I'm searching incorrectly.
I am relatively sure that I have seen it somewhere in the past, but I am not able to recall where.

Having said that, I think it is sort of indirectly said in the https://docs.perl6.org/language/quoting documentation:

In https://docs.perl6.org/language/quoting#Word_quoting:_%3C_%3E about the <> word quoting angle brackets:

The angle brackets quoting is like qw

So, if you know qw// in P5 and are willing to take the chance that it works similarly in P6, you've basically have your response. But we all know that P5 and P6, albeit quite similar, are not the same. So, how does qw works in P6? In https://docs.perl6.org/language/quoting#Word_quoting:_qw:

The :w form, usually written as qw, splits the string into "words". In this context, words are defined as sequences of non-whitespace characters separated by whitespace. The q:w and qw forms inherit the interpolation and escape semantics of the q and single quote string delimiters, whereas Qw and Q:w inherit the non-escaping semantics of the Q quoter.

So, qw inherit the interpolation and escape semantics of the q and single quote string delimiters. Now, you have the answer.

And just in case you're not sure what the interpolation semantics of the q and single quote string delimiters, you can move one step further and look at the q semantics in https://docs.perl6.org/language/quoting#Escaping:_q, which does escaping but no interpolation, as opposed to qq which does interpolation (https://docs.perl6.org/language/quoting#Interpolation:_qq) and to Q (https://docs.perl6.org/language/quoting#Literal_strings:_Q), which produces as literal string as possible.

So, all in all, stevieb, it is really obvious. ;-) (Just kidding, of course.)

Oh, BTW, back to the OP, the behavior is also documented in https://docs.perl6.org/language/operators#index-entry-hash_indexing_operator-hash_subscript_operator-hash_indexing_operator:

Shortcut for postcircumfix { } that quotes its argument using the same rules as the quote-words operator of the same name.
So, again, it is just obvious. ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1200917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-24 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found