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

Re: Angle quotes and pointy brackets

From:
Alexey Trofimenko
Date:
November 29, 2004 16:18
Subject:
Re: Angle quotes and pointy brackets
Message ID:
opsh84fs08sspxk8@80.250.183.187
Matthew Walton wrote:
> James Mastros wrote:
>> Larry Wall wrote:
>>
>>> On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote:
>>> : ah, I forget, how could I do qx'echo $VAR' in Perl6? something like   
>>> : qx:noparse 'echo $VAR' ?
>>>
>>> I think we need two more adverbs that add the special features of qx  
>>> and qw,
>>> so that you could write that:
>>>
>>>     q:x/echo $VAR/
>>>
>>> where ordinary qx/$cmd/ is short for
>>>
>>>     qq:x/$cmd/
>>   I think I'd like that much better if we consider execution and  
>> word-splitting to be the primary operations, and interpolation and  
>> noninterpolation the adverbial modifiers then the other way around,  
>> making that qx:q/echo $VAR/ or qx:qq/$cmd/.

especially because adverbs are meant to say "how to do" rather than "what  
to do", aren't they?

>>  OTOH, I expect backticks to be rare enough that I wouldn't mind writing
>>      use Spawn 'spawn';
>>     spawn :capture :wait ($cmd);
>>     spawn :capture :wait ('echo $VAR');

> Although I'm masochistic enough that I don't mind the idea of always  
> having to do execution with qx//, qx:q// or qx:qq// (running with other  
> suggestions, I'd guess that would be non-interpolating execution, then  
> the same again more explicitly, then interpolating execution) but I do  
> like the idea of spawn.

hm.. qx:q//  qx:qq//

...compare with:
      qx q//  qx qq//

so there's no need in adverbs. But we have no need in qx either. Why to  
introduce (or REintroduce) something if we have something similar already?

      $captured = system :capture q/cmd../;

or maybe even:
      (code=>$code, out=>$captured, err=>$err) = system qq/cmd/;

or maybe even(!)
      $captured = slurp qq/$cmd |/;

> Kind of removes the idea of pulling in the output of other programs as a  
> fundamental part of the language though, for that it's nice to have an  
> executing, capturing quote. Perhaps an adverb to qx that makes it behave  
> like system() - I don't think it'd be a good idea to provide one that  
> makes it behave like exec(), although perhaps other people do.

  I haven't that long unix background, and spawning processes is a very  
*fat* operation for me.. maybe after year or two I'll change my point of  
view, but for now I would be pretty happy with a 'slurp' variant. IMHO,  
spawning processes has nothing to do with other quoters, and perl already  
went far away from shells.

but talking about oneliners and short shell-like scripts, where `` is  
pretty useful.. hm.. things good for oneliners are rarely as good for  
larger programs, and vice versa. Of course, Perl5 proves opposite, but  
Perl6 tends to be a little more verbose, and even in Perl5 we use quite  
different "toolbox" and style for mentioned above. Why not to make an  
average sized module of various "shortcut" grammars, with a very short  
name ("x", f.e.), with defaults to export :all, so we could just do
   perl -Mx -e 'print `echo this is a perl5qx`'

even if `` would be taken for something more useful in Perl6,
and still be able to import only something useful for our larger program  
with
  use x qw/:perl5qx/;



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