Proof of concept for v2 - NO duplication, NO `static if` hell, NO difficulty with interoperability
jmh530
john.michael.hall at gmail.com
Mon Nov 1 15:00:10 UTC 2021
On Monday, 1 November 2021 at 13:18:07 UTC, Andrei Alexandrescu
wrote:
> [snip]
>
> The problem with C++ concepts is that they invent yet another
> language on the top of the three C++ already has in it. It is a
> massive mistake, though not big enough to destroy the language.
> C++ continues to be successful in spite of it, not because of
> it.
>
> The right way is to express concepts within the current
> language and algebra, as D does.
I know that it is kind of tangential to the PoC, but the point
that was raised is that concepts/etc resolve the issue of the
"proper documenting of API's". Your response is that concepts are
bad because they create a new language and it is better to
express them within the current language, as in D. This is all
fine, but it doesn't resolve the issue of "proper documenting of
APIs" issue. Both points can be valid at the same time (concepts
might be bad for the reasons you mention but D may still have an
underlying issue wrt proper documenting of APIs).
My hope was that DIP 1023 (Resolution of Template Alias Formal
Parameters in Template Functions [1]) would help on this issue,
but it has been postponed and I believe the original author has
moved on. Regardless, the code below has the example of an
template alias that is used like a C++ concept.
```d
template Foo(T)
if (is(T == int))
{
alias Foo = T;
}
void foo(T)(Foo!T x) { }
void main() {
Foo!int x;
foo(x); //doesn't compile
foo!int(x); //compiles
}
```
The only problem is the resolution. I don't see why you would
need concepts in D if this issue is resolved.
[1]
https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md
More information about the Digitalmars-d
mailing list