Asking for the opinion of DMD developers

Stefanos Baziotis sdi1600105 at di.uoa.gr
Sun Oct 13 10:51:52 UTC 2019


Hello everyone,

I'm the author of DIP 1023 [1], [2].

I'll try to keep this short to save you time by only mentioning 
the important
parts (and those are a lot anyway).
Feel free to ask me to elaborate on anything that it's not clear.

So, first of all, D can't cope with alias templates used as 
function
parameters (in template functions). For example:

struct TypeTemplate(T) {}
alias AliasTemplate(T) = TypeTemplate!T;
void functionTemplate(T)(AliasTemplate!T arg) {}

void main()
{
     AliasTemplate!int inst;
     functionTemplate(inst); /* "cannot deduce function from 
argument types !()(TypeTemplate!int)" */
}

DIP 1023 was introduced because the reasoning was that this is 
not simply
a bug and the feature was in fact, under-specified.
That is, a bug is when we have the form "When I do X, Z should 
happen" but
it doesn't. "Under-specified" means that "When I do X, it's not 
even clear
that Z should happen in the first place".
So, this is where the compiler writer requests a specification 
addition.

My position is that while I believe that Alias Templates are in 
general
under-specified in D, adding any more specification won't help
DMD writers _in this specific issue_.

Let me elaborate: Let's say that we do have a good enough 
specification,
like C++'s.

With the help of Nicholas Wilson who asked on reddit, I was 
redirected
to the C++ standard [3] in the sections 17.6.7 Alias Templates
and 17.5 Type Equivalence.

I think having such a specification won't help anyone here.
To be even more specific, as far as I can understand,
the issue at hand is handled in the C++ standard with 3 sentences 
(point 2,
section 17.6.7):

"When a template-id refers to the specialization of an alias 
template, it is equivalent to the associated type obtained by 
substitution of its template-arguments for the 
template-parameters in the type-id of the alias
template".

And this something that we already know, yet can't solve the 
issue.

What's your opinion on this ?

Btw, please consider that this is not my area of expertise. :)

Best regards,
Stefanos Baziotis

[1] https://github.com/dlang/DIPs/pull/176
[2] 
https://forum.dlang.org/post/dnyqxmgdazczwmmvayjx@forum.dlang.org
[3] 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4713.pdf



More information about the Digitalmars-d mailing list