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

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
From:
Uri Guttman
Date:
June 22, 2021 19:04
Subject:
Re: RFC: Multiple-alias syntax for for
Message ID:
0ca76e01-0e39-953e-81ca-30eff9f4da79@stemsystems.com
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) {

uri


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