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

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

Thread Previous | Thread Next
From:
Neil Bowers via perl5-porters
Date:
March 6, 2021 23:38
Subject:
Re: Perl feature wish: quote-word array-ref operator
Message ID:
48dfafbc-d0e4-446c-91f8-d9bdd5ca8eb7@Spark
> > $a = qa[ one two three ];
>
> For what it’s worth, I don’t think I’ve ever wanted anything like this. Maybe it’s just me.

I doubt it’s just you, and I think that’s ok. Some changes to the language will be very widely used (defined-or, I suspect falls in this category). And others maybe not so much. I’ve had no desire to use post-deref, for example, though I’m told that if I tried it for a while, I wouldn’t want to go back.

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
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 ];

This is something that I’ve wished we had for a good few years, but I’m not dead-set on getting it in. I thought it would be good to follow through the process with a relatively small / simple example.


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