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

2006-08-30 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 g Apologies to Carl if I misinterpreted. I read it as: can hardly be blamed for (having) clarity ;-) No, yours is the correct

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. g -- Affijn, Ruud Gewoon is een tijger.

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) available,

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) available,

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

2006-08-29 Thread Mark A. Biggar
Carl Mäsak wrote: Yobert Hey do you know what would be cool in perl 6 Yobert A special variable for when you do a for (@array) style loop Yobert 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 = moose

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 reset by redo an some that are

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

2006-08-29 Thread Carl Mäsak
Mark (), Carl (): Yobert Hey do you know what would be cool in perl 6 Yobert A special variable for when you do a for (@array) style loop Yobert 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 =

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 (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

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 code,

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 perfectly

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 g -- Affijn, Ruud Gewoon is een tijger.

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 g 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: Ruud: Damian: Carl: But it can hardly be blamed for clarity. That's a little unfair. can hardly be blamed - can easily be praised g Apologies to Carl if I misinterpreted. I read it as: can hardly be blamed for (having) clarity ;-) Nah, I was just joking;

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 such