On Thursday, 26 March 2015 at 19:45:19 UTC, Alex Parrill wrote:
On Thursday, 26 March 2015 at 19:32:53 UTC, Idan Arye wrote:
...snip...
So tl;dr; make the template constraints in ddoc less prominent?
The "new library reference preview" under Resources seems to
already have this (example:
http://dlang.org/library/std/algorithm/searching/starts_with.html)
This will not solve the readability problem:
- what is a range?
- what is a needle?
- what is a predicate?
Phobos is reinventing the OOP encapsulation without providing the
minimal tools. IMHO, something similar to "interface" is
mandatory to define constraints for "range" and the relationship
between "needle" and "range". In another topic, someone proposed
the keyword "constraint" - or - extend the concept of "interface"
to other kind of types than classes and this will allow some
compile-time interface implementation. Therefore, when I write:
void foo(IInputRange range) { ... }, range can be a class
implementing IInputRange or any other type which supports the
same calls described by IInputRange.
Another approach is to provide enough overloads for most used
scenarios, like testing for prefixes in a string with case
sensivity or not.