develooper Front page | perl.perl6.language | Postings from November 2004

Re: Angle quotes and pointy brackets

From:
Alexey Trofimenko
Date:
November 29, 2004 17:05
Subject:
Re: Angle quotes and pointy brackets
Message ID:
opsh86mkxcsspxk8@80.250.183.187
On Sat, 27 Nov 2004 11:36:14 +0100, James Mastros <james@mastros.biz>  
wrote:

> Larry Wall wrote:
>> Likewise a qw/a b/ is short for
>>      q:w/a b/
>        qw:q/a b/
>        $fromvar = 'foo bar';
>        qw:qq/a "something with spaces" b $fromvar/
>        # ?? -- slightly OT, but is that a, '"something', with, 'spaces"',
>        # b, 'foo bar', or... um, what?  Is qw smart enough to allow
>        # internal quotes?  Does splitting take place before or after
>        # interpolation if it's interpolating?

I like the idea that q would be the most general quoter, which could be  
used (with corresponding adverbs) instead of qq, qw, and heredoc, but qq  
and qw still exists in core as handy shortcuts for most frequent variants.
something like (abstract)
  &qq ::= &q.assuming(:qq)
(I don't know how to write it correctly - q isn't a function..)

...

  :s(0) adverb for specifying "interpolating level"  for quoters seems  
kinda strange to me. First, it is harder to remember numbers than  
something symbolic. Second, there's going to be several interpolation  
layers, and some of them are independent of others, so having only one  
argument is insufficient.

we would (not) want to interpolate:
  variables, functions, methods,
  \n \t and alike,
  backslashed delimiters
  backslashed backslashes
  ... and something also, i forgot what exactly:)
  and someone could want only some of the options..

"heredocness" should be just an adverb for all other type of quotes.

personally I would be very glad to have "shell-like" quoting in qw, as  
James Mastros suggests above. It could save many keystrokes in definition  
of long lists where one occasional space-containing element happens to  
exist.

some other cool variants:
   heredoc-qw which would see only \n as elements delimiter, and would  
strip leading and ending whitespace (for system)
   heredoc-qw for list of lists (\n as a row separator)
   heredoc-qq without ending "\n"
I think, some interesting variants of scalars quoting could be borrowed  
 from YAML(serialization language). think of folded scalars, #comments etc..

hmm.. maybe someone has ideas how to add custom behaviours for q without  
rewriting it? I mean, how to define custom :adverb for it..



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About