On 2010-07-23, at 4:25 am, Moritz Lenz wrote:
> I'm still not convinced.  [that there should be a special index variable]
> Yes, it would be convient, but I've yet to see a non-contrived example where 
> it's actually necessary, and which can't be implemented trivially with other 
> Perl 6 tools.

I see it like the situation with "self".  Sure, it's not necessary, it's easy 
to specify it explicitly, and so on, but nevertheless it feels somehow too 
heavy not to deserve some sugar.  My own first instinct was to use map or a 
loop to produce those a series of squares or factorials or whatever... on the 
other hand, the series operator does naturally come to mind when you're 
thinking about a series!

> The series code is already rather complex (and thus slow), and having to add 
> introspection to find out whether the production code object accepts a named 
> parameter 'i' is not going to help in any way.

I do agree that having a special named parameter isn't the way to do it, 
though.  What if there were a special keyword instead? (Again, like the 
situation with 'self'.)  If you used the word "index" (or "counter" or "n"?) in 
a loop or series or anywhere else suitable, it could be detected at 
compile-time.  It shouldn't be any worse than making your own counter, and 
might even be better (since Perl needs its own counter for some loops, maybe it 
could make it available rather than having to define one of your own as well).


Reply via email to