Re: Apo2: \Q ambiguity not a problem

2001-05-04 Thread Larry Wall

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



Re: Apo2: \Q ambiguity not a problem

2001-05-04 Thread David L. Nicol



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.


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

in p6 without "weird brackets" I supposed this becomes

print "the time is now $(+localtime)\Q[go home!]"; 

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

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


Garrett Goebel wrote:
> 
> From: Larry Wall [mailto:[EMAIL PROTECTED]]
> > Richard Proctor writes:
> > : In Apocalypse 2, \Q is being used for two things, and I
> > : believe this may be ambiguious.
> > :
> > : It has the current \Quote meaning admitibly \Q{oute} it is
> > : also being proposed for a null token disambiguate context.
> > : As in $foo\Q[bar].
> >
> > Hmm, yes, that's a problem.  I'd forgotten about the quotemeta kludge.
> > I'll have to think about it.  Maybe quotemeta becomes \qm{}
> > or some such.
> 
> The problem with \Q quotemeta was the biggest thing to jump out at me when
> reading A2... That is before my brain turned to mush. Seems like quotemeta
> be serving its purpose if you have to consider escaping its contents...
> What's the Perl6 equivalent to:
> 
> #!perl -w
> # script.pl:
> my ($match, $filename) = @ARGV;
> local $/;
> open FH, $filename;
> $file = ;
> print scalar @{[$file =~ m/(\Q$match\E)/gs]};
> 1;
> __END__
> 
> file.txt contents:
> {foo}\E{foo}\E{foo}
> 
> > script.pl {foo} file.txt
> 3
> >

-- 
  David Nicol 816.235.1187 [EMAIL PROTECTED]
  Parse, munge, repeat.