protocol for using InputRanges

Rainer Schuetze r.sagitario at gmx.de
Thu Mar 27 12:21:02 PDT 2014



On 27.03.2014 09:42, Walter Bright wrote:
> 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(); }

This loop is intuitive. Not being allowed to call empty or front 
multiple times or not at all is unintuitive. They should not be named as 
if they are properties then.

>
> 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.

I guess gcc doesn't use patterns here, but value propagation and notices 
that all the checks are unnecessary.


More information about the Digitalmars-d mailing list