Timothee Cour:

Where do you think it can cause clashing?

I don't know.

But my solution is to introduce a simple "enumerate" range:
http://d.puremagic.com/issues/show_bug.cgi?id=5550

So if you have a range and you don't need indexes you use:

foreach (item; myrange) {}

If you also want an index:

foreach (index, item; myrange.enumerate) {}

This is the solution used by Python, it's clean, and it doesn't make the foreach syntax & compiler more complex. Later the compiler should optimize this idiom well.

Bye,
bearophile

Reply via email to