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

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
Paul "LeoNerd" Evans
June 10, 2021 21:53
Re: RFC: Multiple-alias syntax for for
Message ID:
On Thu, 10 Jun 2021 14:04:59 +0200
Salvador FandiƱo <> wrote:

> This is probably going out of control but...
> How about extending "for" with attributes?

I have often wanted that sort of thing (I call them "adverbs") in a
huge number of other places in perl. Far too many cases to list all of
them, but a couple of notable ones:

  $str =~ s:nth(2)/foo/bar/;  # substitute just the 2nd match

  my @result = await map :concurrent(4) { afunc($_) } @items;

Such a thing could be an interesting idea, but it's a huge interesting
idea that involves lots of staring at lots of places, to see where and
how it might make sense.

First problem is that the syntax is too ambiguous: 


is a call to the function &concurrent, taking the params (4), and the
statement happens to have a label `map:`. That colon notation gets in
the way alllll the time.

Annoyingly, I can't think of a good solution that doesn't start to
become whitespace-dependent; i.e. that

  map: concurrent(4)

  map :concurrent(4)

would need to have different meanings. And everyone is going to shoot
me for that idea.

Paul "LeoNerd" Evans      |  |

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