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

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

Thread Previous | Thread Next
Felipe Gasper
March 7, 2021 00:19
Re: Perl feature wish: quote-word array-ref operator
Message ID:

> On Mar 6, 2021, at 6:38 PM, Neil Bowers via perl5-porters <> wrote:
> This sort of small change to a language should satisfy a number of criteria, including:
> 1. the area under the benefit x adoption curve should be enough
> 2. it should be consistent with the language
> 3. hopefully improve readability / maintainability, and at least not reduce those

It’s hard to gauge this, of course, because concision here--which is a win--comes at the cost of adding vocabulary to the language, which is a loss. It seems relatively esoteric syntax at that, expanding on an area of Perl--the q* operators--that I think trips up a lot of newcomers.

> 4. make life easier for people learning the language
> Writing qa[ one two ] rather than [qw/ one two /] feels like I’m writing something closer to what I’m thinking.
> There’s enough evidence that people want to write something like this.
> I feel like it fits in the language, and it would be easy to explain / compare
>     @words = qw( one two );
>     $wref  = qa[ one two ];

In all of your examples I see you using square brackets. What if someone uses parens, braces, fore-slashes, etc.?


1) Will someone intuit what `return qa( foo bar )` does?

2) Will someone intuit that `qa( foo bar )` is closer to qw than to q or qq?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About