On 03.09.2016 12:33, Walter Bright wrote:
On 9/3/2016 3:14 AM, Timon Gehr wrote:
On 03.09.2016 10:37, Walter Bright wrote:
None of the algorithms used in std.algorithm or elsewhere in Phobos have
this particular issue.
Yes they do. It is not possible to implement the range functions as
non-members.
It's done for arrays via std.array.
...
This is not at all relevant when talking about 'this particular issue'
that Manu brought up. std.range and std.algorithm import std.array.
Nor have I seen ADL supported in any other
language, despite many supporting generic algorithms.
Which other such languages have templates like D or C++?
I don't think it is a template issue. It's a name lookup issue.
It's both. ADL is mostly useless outside of generic code. It's mostly
about how templates specify what interface they require and how the
requirements are satisfied by the caller. ADL is a workaround for the
lack of a convenient enough such protocol in templates. Other approaches
to generics solve this particular issue quite elegantly. (E.g. type
classes implicitly pass along the required free-function functionality.)
D's templates don't, this is why it is a template issue.
By default, name lookup does not work in a way that would allow you to
actually extend types using UFCS, and therefore none of Phobos works
that way.
Note that I'm not saying ADL should be implemented, but the problem it
addresses is real, and it exists in D.
There's LINQ in C#, for example.
C# does not have templates.