It's basically Hindley-Milner.
Elfstone
elfstone at yeah.net
Fri Mar 24 10:35:40 UTC 2023
On Friday, 24 March 2023 at 09:44:28 UTC, FeepingCreature wrote:
> If we insert the missing step, what the compiler should do is:
> "Ah, `B` is a 'trivial alias' (like `using` in C++), so I can
> *syntactically substitute* it with its content", and create the
> new expression `B!int = B!T`. Then it can resolve this by
> noting that *the concrete type* `B!int` is an instance of `B`
> with the type `int`, and thus gain the new expression `T =
> int`, which solves the algebraic system.
That alone will be a huge improvement.
There's no need to resolve all cases. DIP1023 should not try to
do that, if it's ever picked up.
```C++
template <typename T>
using Identity = int;
template <typename T>
void bar(Identity<T> id) {
}
int main() {
bar(Identity<int>());
}
```
C++ doesn't automatically resolve this either, and I bet no one
will ask it to.
When you think about it: for now, D allows writing template alias
paramters, but AFAIK they will match absolutely **nothing**!
Nothing you pass will ever be accepted.
More information about the Digitalmars-d
mailing list