On Mon, Aug 28, 2000 at 04:10:01PM -0400, Eric Roode wrote:
> Peter Scott wrote:
> >Graham Barr once allowed as how he thought it would be neat if you could say
> >
> >     for my($x, $y, $z) (@list) { ... }

I too am pushing for this feature, to the point where I'm considering
an rfc on the topic.

> ObLanguageMinimalist:
> 
> Um. Is this so frequently-used that the above syntax is preferable to:
> 
>     while ( ($x, $y, $z) = splice (@list, 0, 3) )   {...}
> 
> ? (notwithstanding the destructive nature of splice)

I contend that being able to say

   foreach ( $height, $width, $depth ) ( @dimensions ) { ...  }

is considerably more intuitive (reader-friendly, writer-friendly)
and considerably more efficient than the `while' equivelent.  It
also dovetails very nicely with RFC120 on index vars.

Allowing list assigns in the loop also gives you other nice
terse perlisms like:

   my @dim = ( undef, undef, undef );
   foreach ( @dim ) ( @dimensions ) { &func( \@dim ) }

and 

   my @dim1 = ( undef, undef, undef );
   my @dim2 = ( undef, undef, undef );
   foreach ( @dim1, @dim2 ) ( @dimensions ) { &compare( \@dim1, \@dim2 ) }


Reply via email to