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

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 10, 2021 21:53
Subject:
Re: RFC: Multiple-alias syntax for for
Message ID:
20210610150856.607c5715@shy.leonerd.org.uk
On Thu, 10 Jun 2021 14:04:59 +0200
Salvador FandiƱo <sfandino@gmail.com> 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: 

  map:concurrent(4)

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

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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