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:
eg:
elements.map!( (a) {preaction(a); auto b=transform(a); postaction(a,b);
return b;}) . filter/sort/map/etcWith what I proposed, it is possible, and it guarantees the lambda will be called once at most per element. On Thu, Oct 24, 2013 at 8:55 AM, Chris <[email protected]> wrote: > On Thursday, 24 October 2013 at 15:40:22 UTC, Dicebot wrote: > >> On Thursday, 24 October 2013 at 15:36:59 UTC, Chris wrote: >> >>> How do you define side effects? After all ranges manipulate, reformat or >>> restructure data. >>> >> >> They should do it in popFront. I'd consider any `front` that does >> anything but accessing cached value suspicious. >> > > So code like > > auto front() { > doSomething(); > return range[0]; > } > > should go into > > void popFront() { > doSomething(); > range = range[1..$]; > } >
