Re: Implicit current-index variable, scoped inside for-loops

2006-08-30 Thread Dr.Ruud
Damian Conway schreef: > [for @array -> $index, $value {...}] > > No. There's no such magic. I simply screwed up. I should have written: > for @array.kv -> $index, $value {...} > :-( Ah, much clearer now. -- Affijn, Ruud "Gewoon is een tijger."

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Carl Mäsak
Damian (>), Ruud (>>), Damian (>>>), Carl (): > >> But it can hardly be blamed for clarity. > > > > That's a little unfair. > > "can hardly be blamed" -> "can easily be praised" Apologies to Carl if I misinterpreted. I read it as: "can hardly be blamed for (having) clarity" ;-) No,

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Damian Conway
for @array -> $index, $value { say "Element $_ is called $value" } But I don't understand how the "$index, $value" pair gets its values; is @array somehow turned into a hash with the index as the key? With @array -> $index, $value {}, is $_ an alias of $index? No. There's no

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
"Damian Conway" schreef: > Ruud: >> Damian: >>> Carl: But it can hardly be blamed for clarity. >>> >>> That's a little unfair. >> >> "can hardly be blamed" -> "can easily be praised" > > Apologies to Carl if I misinterpreted. I read it as: > "can hardly be blamed for (having) clarity" >

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Damian Conway
>> But it can hardly be blamed for clarity. > > That's a little unfair. "can hardly be blamed" -> "can easily be praised" Apologies to Carl if I misinterpreted. I read it as: "can hardly be blamed for (having) clarity" ;-) Damian

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
Damian Conway schreef: > [attribution repaired] Carl: >> But it can hardly be blamed for clarity. > > That's a little unfair. "can hardly be blamed" -> "can easily be praised" -- Affijn, Ruud "Gewoon is een tijger."

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Damian Conway
pugs> map { "Element $^a is called $^b" }: @array.kv; ("Element 0 is called london", "Element 1 is called bridge", "Element 2 is called is", "Element 3 is called falling", "Element 4 is called down") But it can hardly be blamed for clarity. That's a little unfair. Choose good names and it's per

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Jonathan Scott Duff
Having read this thread, I tend to think you're insane for bringing it up again :-) That said, I'll entertain the discussion for a bit ... On Tue, Aug 29, 2006 at 08:33:20AM +0200, Carl Mäsak wrote: > Questions: > > - Is the itch big enough for this? The more I look at the first piece > of cod

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
Carl Mäsak schreef: > I suppose doing a map or a grep over @array.kv is possible: > > pugs> my @array = > ("london", "bridge", "is", "falling", "down") > > pugs> map { "Element $^a is called $^b" }: @array.kv; > ("Element 0 is called london", > "Element 1 is called bridge", > "Element 2 is call

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Carl Mäsak
Mark (>), Carl (>>): > Hey do you know what would be cool in perl 6 > A special variable for when you do a for (@array) style loop > it would always have the index of the array > > Discussed on #perl6: it's already quite easy in Perl 6 to loop with an > explicit index: > > my @array = ; > for

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
"Carl Mäsak" schreef: > Ruud: >> Carl: >>> But maybe a variable that implicitly carries along the loop index >>> would be even snazzier? >>> >>> for @array -> $val { >>> say "$.\t$val"; >>> } >> >> Or give the block a name (label), and have an index (or several >> indexes, like some that are res

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Mark A. Biggar
Carl Mäsak wrote: Hey do you know what would be cool in perl 6 A special variable for when you do a for (@array) style loop it would always have the index of the array Discussed on #perl6: it's already quite easy in Perl 6 to loop with an explicit index: my @array = ; for @array.kv -> $i, $v

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Carl Mäsak
Ruud (>), Carl (>>): > But maybe a variable that implicitly carries along the loop index > would be even snazzier? > > for @array -> $val { > say "$.\t$val"; > } Or give the block a name (label), and have an index (or several indexes, like some that are reset by redo an some that are not) avai

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Ruud H.G. van Tol
Carl Mäsak wrote: > But maybe a variable that implicitly carries along the loop index > would be even snazzier? > > for @array -> $val { > say "$.\t$val"; > } Or give the block a name (label), and have an index (or several indexes, like some that are reset by redo an some that are not) availabl

Implicit current-index variable, scoped inside for-loops

2006-08-28 Thread Carl Mäsak
Hey do you know what would be cool in perl 6 A special variable for when you do a for (@array) style loop it would always have the index of the array Discussed on #perl6: it's already quite easy in Perl 6 to loop with an explicit index: my @array = ; for @array.kv -> $i, $val { say "$i\t$val