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

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

Thread Previous | Thread Next
From:
Alexander Hartmaier
Date:
March 11, 2021 08:29
Subject:
Re: Perl feature wish: quote-word array-ref operator
Message ID:
CAB49Qrabv+Xc56A+=LEqq2dPkUC-x9YZig+3Xhqp6rPpHPRdwA@mail.gmail.com
On Wed, Mar 10, 2021 at 7:10 PM Veesh Goldman <rabbiveesh@gmail.com> wrote:

> I'm relatively new to Perl, compared to most people here (4 years now,
> only 2 professionally).
>
> At first I didn't know about the qw operator at all. Once I found it, I
> was in love with it. I may be an exception, but I enjoy learning new idioms
> and syntax that help make the code more succinct.
>
> That's why I really like the qa suggestion. It may be a new thing to
> learn, but it empowers you.
>
> Happens to be, I was thinking along the lines of modifiers, like someone
> suggested. Especially an 'x' modifier which would allow comments in a qw or
> qw-like construct.
>
> that's my 2 cents
>
> On Wed, Mar 10, 2021 at 7:55 PM Martijn Lievaart <m@rtij.nl> wrote:
>
>>
>> Op 10-03-2021 om 17:12 schreef Felipe Gasper:
>> >
>> >> On Mar 10, 2021, at 3:09 AM, Smylers <smylers@stripey.com> wrote:
>> >>
>> >> Felipe Gasper writes:
>> >>
>> >>> Perl, for better or for worse, suffers a reputation as being hard to
>> >>> read. In that light, I do think special care is justified when adding
>> >>> additional ways to do everyday tasks like creating an array reference.
>> >> As Eirik said, I think this makes code _easier_ to read. Less
>> >> distracting clutter of multiple nested brackets, or trying to work out
>> >> what each do.
>> > As I wrote earlier, there are wins and losses. Less syntax is a
>> readability win, but having multiple ways to do familiar things is a loss.
>> For example, if I write:
>> >
>> > my $foo = [ 1, 2, 3 ];
>> >
>> > my %bar = (
>> >      abc => qa/a b c/,
>> >      def => qa/d e f/,
>> > );
>> >
>> > my @baz = qw/ ha ha ha /;
>> >
>> > … then someone has to grok both syntaxes for arrayref-literal creation,
>> as well as qw, in order to comprehend the code.
>>
>> /delurk
>>
>>
>> I am an oldtimer, but the code above reads as a win for me. Extremely
>> easy to grok.
>>
>>
>> M4
>>
>>
>> What I hate about quoting in Perl in general is that it doesn't allow to
use the dash! my %hash = ( foo-bar => 'baz' ); doesn't work and needs to be
quoted.

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