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

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

Thread Previous | Thread Next
From:
Felipe Gasper
Date:
March 7, 2021 00:19
Subject:
Re: Perl feature wish: quote-word array-ref operator
Message ID:
553F530E-7B0C-4EB9-B5E8-4FC8D662B5E7@felipegasper.com

> On Mar 6, 2021, at 6:38 PM, Neil Bowers via perl5-porters <perl5-porters@perl.org> 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.?

Consider:

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?

-F
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