protocol for using InputRanges

Walter Bright newshound2 at digitalmars.com
Thu Mar 27 01:42:42 PDT 2014


On 3/26/2014 11:53 PM, Rainer Schuetze wrote:
> IIUC what you are proposing would be covered better by removing front and return
> the value by popFront.

Different things being ranged over make different decisions as to what goes into 
each function.

> Instead of forcing strong, breaking and sometimes unintuitive semantics

I don't understand what is so unintuitive about:

     while (!empty) { ... front ...; popFront(); }

What I do find unintuitive and unattractive is all those flags in the range 
implementation.

> we could also improve dmd's optimizer.

Yes, that's true. The thing about optimizers, though, is they work on patterns. 
If your code doesn't quite match the right pattern, it won't tickle the 
optimization you might be expecting. The pattern for recognizing the ROL and ROR 
patterns is one such.


More information about the Digitalmars-d mailing list