David L. Nicol writes:
: Not a problem.  \Q means quotemeta, except immediately following
: a interpolated identifier.  You want to start metaquoting immediately
: after a curious interpolation? use \Q\Q.

The word "except" should be a red flag that you're trying to define an
exception.  We're trying to reduce the number of exceptions these days,
at least in the areas where context sensitivity doesn't buy you power.

: I have been regularly, since I fingured out how, doing things like
: 
: 
:       print "the time is now ${\(~~localtime)}[go home!]";  # double-not
: "scalar" golf hack

Er, if you've been doing things like that, then you must be fond of
syntax errors.  Those are not "weird brackets", they're just dereference
brackets.  Perl 5 keeps parsing the expression after ${}, so [go home!]
is a subscript.

The ~~ is a cute hack though.

Weird brackets are only of the form ${foo[bar]} or ${foo{bar}}.  We're
not proposing to get rid of ${foo}[bar], except insofar as we're making
it do the same thing inside quotes as outside, which it doesn't right
now.

: in p6 without "weird brackets" I supposed this becomes
: 
:       print "the time is now $(+localtime)\Q[go home!]"; 

I think $() will end interpolation automatically (since you could
always put the subscript inside if you really want it), so the \Q
wouldn't be necessary.  And you don't want + there unless you want it
numified, I suspect, though I could change my mind on that.  The $()
already puts it in scalar context.

: Right?  So if I wanted to quotemeta this thing so I could let sh have it
: safely, what in apo2 is preventing me from writing
: 
:       print "the time is\Q now < $(+localtime)\Q[go home!] \E"; 
: 
: the only time there's an ambiguity is when the metaquoting starts
: immediately
: after the stopped variable identifier

I'm sorry, my eyes go crossed when I look at that, and the two \Q's
merge into one, which confuses me, in a stereoscopic sort of way.

:       print SH "echo the time is now `date` so go $destinations{first}\Q\Q
: <$tainted> \E"; 
:  perl -le'print "\Q\Q\Q <<\E<\E< \E <"'
: \\\\\\\ \\\\\\\<\\\\\\\<\\\<\<\  <
: 
: metaquote stacks -- why not use \E instead?  it has the same issues, but
: has
: no effect at all currently, and E is for End_of_interpolble_specifier a lot
: more than \Q does.
: 
: \Q\E is a safe zero-length noninterpolable in any context however, with
: no side effect

We could leave \Q{} as metaquote and use \E for a expression stopper,
though that would be confusing to people used to the old \E, which is
dead, dead, dead, drive a stake through its heart, dead.  (I hope...)

Larry

Reply via email to