On Saturday, 3 September 2016 at 10:56:20 UTC, Tobias M wrote:
On Saturday, 3 September 2016 at 10:33:22 UTC, Walter Bright wrote:
I don't think it is a template issue. It's a name lookup issue. There's LINQ in C#, for example.

I think it is.

The problem is lookup of dependent symbols (see C++ two phase lookup). Without real templates, all lookup can be done at definition time. I'm not very familiar with LINQ, but generally C# uses uses interfaces as constraints on generics, similar to traits/type classes. Lookup is then done once, considering only the interfaces, not for each the concrete type.

No, LINQ doesn't work because of interfaces, but because of extension methods (C#'s variant of UFCS). The IEnumerable<T> interface defines only a single method. All the useful functionality is implemented as extension methods which are only available if the user specifically imports the namespace in which where they're defined (just like D's ranges and range primitive implementations for arrays). Those extension methods are used as a fallback, similarly to UFCS in D: every type can override the extension methods by implementing the method itself. Also more inner namespaces (more closer to the method invocation) override more outer namespaces. For more info see:

1) https://github.com/ljw1004/csharpspec/blob/gh-pages/expressions.md#member-lookup Member Lookup 2) https://github.com/ljw1004/csharpspec/blob/gh-pages/expressions.md#member-access Member access and 3) https://github.com/ljw1004/csharpspec/blob/gh-pages/expressions.md#extension-method-invocations Extension method invocations
      • Re: ADL Walter Bright via Digitalmars-d
      • Re: ADL Andrei Alexandrescu via Digitalmars-d
      • Re: ADL Timon Gehr via Digitalmars-d
      • Re: ADL Walter Bright via Digitalmars-d
      • Re: ADL Timon Gehr via Digitalmars-d
      • Re: ADL Walter Bright via Digitalmars-d
      • Re: ADL Jacob Carlborg via Digitalmars-d
      • Re: ADL Manu via Digitalmars-d
      • Re: ADL Walter Bright via Digitalmars-d
      • Re: ADL Tobias M via Digitalmars-d
      • Re: ADL ZombineDev via Digitalmars-d
      • Re: ADL Tobias M via Digitalmars-d
      • Re: ADL ZombineDev via Digitalmars-d
      • Re: ADL Tobias M via Digitalmars-d
      • Re: ADL Tobias Müller via Digitalmars-d
      • Re: ADL ZombineDev via Digitalmars-d
      • Re: ADL Tobias Müller via Digitalmars-d
      • Re: ADL ZombineDev via Digitalmars-d
      • Re: ADL Walter Bright via Digitalmars-d
      • Re: ADL Andrei Alexandrescu via Digitalmars-d
  • Re: ADL Timon Gehr via Digitalmars-d

Reply via email to