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

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

Thread Previous | Thread Next
March 10, 2021 08:09
Re: Perl feature wish: quote-word array-ref operator
Message ID:
Felipe Gasper writes:

> > On Mar 7, 2021, at 3:16 AM, Smylers <> wrote:
> > It isn't necessary that every Perl feature be one that a non-Perl-
> > programmer could guess precisely what it does without any documentation.
> > We have qw; qa would be a handy variant, with a similar level of
> > (non-)intuition, thereby keeping the overall intuitiveness level about
> > the same for newcomers — while qa itself being exceedingly intuitive to
> > Perl programmers who already know qw.
> Respectfully, this is a straw-man; I didn’t say that it should be
> necessary (or even strongly preferable) that every Perl feature be
> fully understandable without reading documentation.

My apologies. You mentioned how intuitive something is. There are
different levels of intuition, to different groups of people. I tried to
consider a couple of those, with how it would seem to a beginner being
just one of them.

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

> qa// will save us relatively-few Perl veterans a few keystrokes here
> and there. This is “a bit of a win”. It will also complicate things a
> bit for the (I suspect) relatively-many Perl neophytes out there to
> grok a veteran’s code.

There are many levels between those two extremes. A beginner may not
even use qw at all:

  my @words_list = ('swa_a_p', 'bonk', 'clash');
  my $words_list_ref = [@words_list];

But when they're ready for qw, I don't think they'd find it hard to pick
up qa at the same time.

> Given that disparity of numbers, IMO the liabilities seem rather a
> greater loss than the gain we longtimers will realize.

I'm not sure that [qw/.../] plays that well with beginners either.
Either you have to think about what each of the levels are doing there
and compose them in your head (which is more complex than having a
single construct); or you've internalized the pattern and see it as a
whole (in which case you can definitely cope with the concept of this as
a single operation, and cleaner syntax for it would be an advantage).


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