DIP 1023--Resolution of Template Alias Formal Parameters in Template Functions--Community Review Round 1

Stefanos Baziotis sdi1600105 at di.uoa.gr
Wed Sep 11 11:49:56 UTC 2019


On Wednesday, 11 September 2019 at 05:32:22 UTC, ag0aep6g wrote:
> A "template alias" is nothing but a (simple) template that 
> resolves to an alias.
>
> This:
>     alias Foo(T) = ...;
> is just short for this:
>     template Foo(T) { alias Foo = T; }
> They are exactly the same thing to the compiler.

We should be more precise here. 2 things that are semantically 
the same
might not be the same for the compiler (and the compiler's job is 
to handle
them as the same). A trivial example is this:
```
alias my_int = int;

my_int x;
...
```

my_int and int are semantically exactly the same, but to the 
compiler they're
not. The compiler has to do work to handle them as the same.

I'm not saying that in your example they are or not, because I 
don't know / remember. You might do though.
But this is an important distinction. As far as I remember, 
they're
not handled as the same and I wouldn't think that they're handled 
the same
as well.

As another point, and this is the only important thing to a DIP 
(aka formal
specification): 2 things might be semantically the same but not 
formally
the same. The example above is in that category. The one is an 
alias declaration
and the other a built-in type. But the specification should say 
that they
should be handled the same.

As far as I'm concerned, your example is a template declaration 
that resolves
to an alias declaration, which is different from an alias 
declaration.

- Stefanos


More information about the Digitalmars-d mailing list