<div>Thanks for the enumerate pointer.</div><div><br></div><div>3A)</div><div>why not having an Enumerate(R) containing a single 'opApply' public method, to avoid returning tuples in 'front()'</div><div><br>
</div><div>3B)</div><div>requiring one to use 'myrange.enumerate' for inputRanges and 'myrange' in other cases is bad for generic programming and user time. This is a very frequent idiom that should just work out of the box. Language is more orthogonal and less surprising in this case. That being said, enumerate still has its value (eg for foreach (i, k, v; associativeArray.byPair.enumerate()) )</div>
<div><br></div><div>3C)</div><div>if no-one can find a concrete argument why it would cause clashing / confusion, I will file an enhancement request for it (dip sounds overkill)</div><div><br></div><div><br></div><div><br>
</div><div class="gmail_quote">On Tue, May 28, 2013 at 10:31 AM, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com" target="_blank">bearophileHUGS@lycos.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Timothee Cour:<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Where do you think it can cause clashing?<br>
</blockquote>
<br></div>
I don't know.<br>
<br>
But my solution is to introduce a simple "enumerate" range:<br>
<a href="http://d.puremagic.com/issues/show_bug.cgi?id=5550" target="_blank">http://d.puremagic.com/issues/<u></u>show_bug.cgi?id=5550</a><br>
<br>
So if you have a range and you don't need indexes you use:<br>
<br>
foreach (item; myrange) {}<br>
<br>
If you also want an index:<br>
<br>
foreach (index, item; myrange.enumerate) {}<br>
<br>
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.<br>
<br>
Bye,<br>
bearophile<br>
</blockquote></div><br>