<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 7, 2016 at 12:44 AM, Chandler Carruth via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span class=""><div dir="ltr">On Sun, Mar 6, 2016 at 11:45 PM Justin Bogner <<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>> wrote:<br></div></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Chandler Carruth via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br></span><span class="">
> This came up in the C++ standards committee meeting, and it seemed like<br>
> a useful construct that LLVM might want as well, and I wanted to<br>
> understand how easily we could solve it. I suspect this can be used to<br>
> write simpler counting loops even in LLVM along the lines of:<br>
><br>
>   for (int i : seq(0, v.size())) {<br>
>     ...<br>
>   };<br>
<br>
I don't get how this gains us anything. this adds a bunch of code to<br>
save, well, three characters over a regular loop:<br>
<br>
    for (int i = 0; i < v.size(); ++i) {<br>
      ...<br>
    }<br></span></blockquote><div><br></div><div>Well it avoids the common mistake made here. ;] The correct comparison would be:</div><div><br></div><div>  for (int i = 0, Size = v.size(); i < Size; ++i) {</div><div>    ...</div><div>  }</div><div><br></div><div>Which is a decent bit longer and requires us to come up with a name for Size. Sometimes, that's really nice, but sometimes its a pain.</div><div><br></div><div>I'm still actually torn on whether this is a useful idiom. But others seemed to think it was in committee, and I was curious what folks in LLVM land think, so figured I'd write it up and see. So hopefully we'll get a few more comments before moving forward.</div></div></div></blockquote><div><br></div><div>Ah, figured you had a use case so I was just reviewing the mechanics.<br><br>I agree with Justin that it'll be more useful when we have some kind of pairwise join (though in that case we might want an unbounded version of this - seq<>() that has an end at INT_MAX or whatever and can be paired with any shorter sequence to add indicies to a range-for iteration), but chicken-and-egg problem, partly, so I'd be happy to see any of these pieces go in in pretty much any order myself.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Chandler</div></font></span></div></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>