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

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
From:
Nicolas Mendoza
Date:
June 10, 2021 02:01
Subject:
Re: RFC: Multiple-alias syntax for for
Message ID:
30f5ac1d-6ab7-b960-aed8-6cb0db33d42e@pvv.ntnu.no

Den 10.06.2021 03:37, skrev Dan Book:
>
>     2) will this work flawlessly with for instance: for my ($key $value,
>     %rest) = (%hash) { … } (iterating only once)
>
>
> I don't see why this should be supported and complicate 
> the implementation, since you can just do that assignment without any 
> loop.

I see I wrote the wrong syntax, I meant that since it is supposed to 
work n-at-a-time, what would it do when having a hash or an array on the 
left side. Would it behave similar to constructs not in a for-loop like 
classical argument assignment (my ($self, $in, %opt) = @_; or just die?

for my ($key, $value, %rest) (%hash) { … } # one iteration or syntax error?

for my ($first, $second, @rest) (@array) { … } # one iteration or syntax 
error?

for my ($a, $b, $c) (@array) { … } # int($#array / 3) + ($#array % 3) 
iterations?

for my (@a) (@array) { … } # one iteration or syntax error

for my ($a, $b, undef) ((1,2,3)) { … } # one iteration or syntax error--

-- 

Nicolas Mendoza


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