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

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
From:
mah.kitteh via perl5-porters
Date:
June 23, 2021 20:34
Subject:
Re: RFC: Multiple-alias syntax for for
Message ID:
hLEyYRKjb1LMPpZo1onwXGmLT2516aSw6W-9IhlM5bES71Ja8nAdoSjUKplFzCiX-bcvBh04xQ2hur94e8bZdCArllzY0cxsgPRrG1_kZcw=@protonmail.ch
The Chapel language has some interesting concepts implemented, and they all have to do with exactly what I meant in my YAPC::Zoom::2021 talk; the lanaguage has no inherent constraints on these kind of concurrent semantics. I claim this is a good thing, it just needs to be recognized and expressed clearly - particularly as it relates to the perl uniprocess.

I say that because this topic reminds me of this, as does pre-RFC for extending hash slices in an expressive way.

Since we're all students of the esoteric, here's a link to Chapel's documentation.

https://chapel-lang.org/docs/language/spec/ranges.html

I highly recommend these specs be studied. It might clarify some ideas and give genesis to new ones.

Cheers,
Brett

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Wednesday, June 23rd, 2021 at 2:11 AM, Nicholas Clark <nick@ccl4.org> wrote:

> On Tue, Jun 22, 2021 at 03:04:31PM -0400, Uri Guttman wrote:
>
> > On 6/22/21 2:58 PM, Ricardo Signes wrote:
> >
> > > On Tue, Jun 22, 2021, at 2:07 PM, David Nicol wrote:
> > >
> > > > Don't recall seeing this case discussed:
> > > >
> > > > my @iters = (undef,undef); # empty list would be
> > > >
> > > > run-time error!
> > > >
> > > >               for @iters ( @iterees) {
> > > >
> > > >                     ... #   $iters[0] is alias to even iterees,
> > > >
> > > > $iters[1] is alias to odd ones
> > > >
> > > >                     # if @iters changes size, next time through it
> > > >
> > > > gets that many
> > > >
> > > >              }
> > >
> > > It's not legal.  The thing after "for" must be a parenthesized list of
> > >
> > > scalar targets.
> >
> > but an easy workaround is this (my guess):
> >
> > for ( $iters[0], $iters[1] ) ( @iterees) {
> >
> > or even with the expansion??:
> >
> > for ( @iters[*] ) ( @iterees) {
>
> None of this is easy to add to the current implementation of 1-at-a-time
>
> foreach loops.
>
> I'm not convinced that it's a good idea making the step size of the iteration
>
> be dependant on the array's current size, as this feels like
>
> action-at-a-distance.
>
> The target(s) of a foreach loop is an alias, not an assignment - to be
>
> consistent with this:
>
> $ perl -E 'my $foo = "Hello"; for $foo ("Boo!") { say $foo; say \$foo } say $foo; say \$foo'
>
> Boo!
>
> SCALAR(0x559598381f38)
>
> Hello
>
> SCALAR(0x5595983721b0)
>
> it's unclear whether the the existing values of the array would be what
>
> was aliased, or the entire array.
>
> I don't think that this discussion is heading in any direction that can
>
> be implemented.
>
> Nicholas Clark

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