develooper Front page | perl.perl5.porters | Postings from March 2021

Re: Perl feature wish: quote-word array-ref operator

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
March 5, 2021 11:21
Subject:
Re: Perl feature wish: quote-word array-ref operator
Message ID:
20210305112111.5a974b1a@shy.leonerd.org.uk
On Fri, 5 Mar 2021 08:48:25 +0000
Neil Bowers via perl5-porters <perl5-porters@perl.org> wrote:

> It would be handy to have a "quote word arrayref operator" in Perl,
> that combines [] with qw.
> 
> So instead of writing:
> 
>     $a = [ qw/ one two three/ ];
> 
> You could write:
> 
>     $a = qa[ one two three ];

Implementation-wise that wouldn't be too hard to add. Though I'd have
one concern about deparse. Namely, what would you expect to see from:

  $ perl -MO=Deparse -ce '$x = [qw[ one two ]]; $y = qa[ three four ]'

Would the deparse show the difference in these originally, or would
they both come out using the same notation? Already a qw[] gets lost:

  $ perl -MO=Deparse -ce '$x = [qw[ one two three ]]'
  $x = ['one', 'two', 'three'];

So perhaps qa would do the same?

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Previous | Thread Next


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