P is for Practical | |
PerlMonks |
Re^2: Small Perl 6 discoveries IV, hash accessby Laurent_R (Canon) |
on Oct 07, 2017 at 21:21 UTC ( [id://1200917]=note: print w/replies, xml ) | Need Help?? |
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. ;-)
In Section
Meditations
|
|