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

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

Thread Previous | Thread Next
From:
Veesh Goldman
Date:
March 10, 2021 18:10
Subject:
Re: Perl feature wish: quote-word array-ref operator
Message ID:
CAO-W_8DyxxEGrLYc+=vvQKVXh4aQeSUOHYFs1RpYwx40PVexWQ@mail.gmail.com
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
>
>
>

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