protocol for using InputRanges

Timon Gehr timon.gehr at gmx.ch
Thu Mar 27 15:48:48 PDT 2014


On 03/27/2014 05:17 AM, Walter Bright wrote:
>
> As with *any* API, if you look under the hood and make assumptions about
> the behavior based on a particular implementation, assumptions that are
> not part of the API, the risk of breakage inevitably follows.
>
> If you've identified Phobos code that uses ranges but does not follow
> the protocol, the Phobos code is broken - please file a bugzilla issue
> on it.

I feel uneasy about the assertion that code that assumes that 'empty' 
checks for an empty range is broken. If the API does not allow fast 
range implementations without arbitrarily restrictions on some 
'protocol', then this is a problem with the API. Maybe 
empty/front/popFront should just be a single primitive, like:

Nullable!T get();


More information about the Digitalmars-d mailing list