<div dir="ltr">that changes semantics: what if you want to do some actions before and after accessing the front element. You'd have to do quite a big of gymnastics to do that in popFront:<div>eg:</div><div>elements.map!( (a) {preaction(a); auto b=transform(a); postaction(a,b); return b;}) . filter/sort/map/etc</div>
<div><br></div><div>With what I proposed, it is possible, and it guarantees the lambda will be called once at most per element.<br><div><br><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Oct 24, 2013 at 8:55 AM, Chris <span dir="ltr"><<a href="mailto:wendlec@tcd.ie" target="_blank">wendlec@tcd.ie</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Thursday, 24 October 2013 at 15:40:22 UTC, Dicebot wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thursday, 24 October 2013 at 15:36:59 UTC, Chris wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How do you define side effects? After all ranges manipulate, reformat or restructure data.<br>
</blockquote>
<br>
They should do it in popFront. I'd consider any `front` that does anything but accessing cached value suspicious.<br>
</blockquote>
<br></div></div>
So code like<br>
<br>
auto front() {<br>
  doSomething();<br>
  return range[0];<br>
}<br>
<br>
should go into<br>
<br>
void popFront() {<br>
  doSomething();<br>
  range = range[1..$];<br>
}<br>
</blockquote></div><br></div>