Phobos uses opSlice and opDollar without checking for it

qznc via Digitalmars-d digitalmars-d at puremagic.com
Wed May 25 08:05:33 PDT 2016


Today I learned [0] that opDollar must be explicitly implemented 
and might not be available by some ranges. Likewise slicing. If 
you think it further, there are lots of functions in Phobos (I'm 
currently looking into std.algorithm.searching) which use more 
features than they check capabilities for. Ranges which satisfy 
isRandomAccessRange do not automatically satisfy hasSlicing.

Can we provide opSlice and opDollar implicitly for random access 
ranges?

Alternatively, we should comb through Phobos to fix the 
capability checks and write unittests with minimalistic ranges.

I already filed issue 16073 [1], but then realized it does not go 
far enough.

Also, std.range.primitives should have a predicate for opDollar 
similar to hasSlicing.

[0] https://github.com/dlang/phobos/pull/4362#discussion_r64576690
[1] https://issues.dlang.org/show_bug.cgi?id=16073


More information about the Digitalmars-d mailing list