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 15:48:55 UTC 2019

On Wednesday, 11 September 2019 at 14:14:31 UTC, ag0aep6g wrote:
> And it might make sense to focus on that difference if you're 
> writing a DIP that changes the meaning of `alias`. But if 
> you're writing a DIP that changes the meaning of `int`, then we 
> expect that is also applies to `my_int`.

It doesn't change the meaning of alias. It changes how
an alias declaration / instantiation acts.

> So unless your DIP states that it changes the meaning of the 
> alias template shorthand syntax, we expect that it also works 
> with the longhand.

It does as far as I'm concerned. It always states alias
declarations [1] and template alias instantiations
with regard to alias declarations.
The "longhand" version is not an alias declaration, it
is a template declaration.

> As far as I understand, you suspect a semantic difference. If 
> that's so, you're simply mistaken.

Firstly, there are things to consider regarding the handling
inside the compiler. Although that has to do with
the implementation, which I don't think we should focus on.

The thing is, semantics is about what something means.
But, regarding formal specifications, there's another
important topic. Actually, the most important for this DIP,
which is how something is resolved to be a specific semantic
The "longhand" and "shorthand" versions are semantically the same,
i.e. they correspond to the same semantic entity, but the way
one arrives to this entity is different. Meaning, the rules
And one should consider that. Otherwise, the burden
is left to the compiler implementor.

> I'm not sure what "formally the same" would entail. 
> Syntactically, the two variants are different (obviously). But 
> that's it. Semantically, the shorthand is defined to mean 
> whatever the longhand means [1].

As I said above, in the way I understand it, one thing 
the same with another is not enough. If that was so, this DIP
would not even be needed since most of its work is to describe
the resolution procedure.

> Syntactically, `template Foo(T) { alias Foo = T; }` is called a 
> "TemplateDeclaration". Semantically, it declares a template.
> Syntactically, `alias Foo(T) = T;` is called an 
> "AliasDeclaration". Semantically, it also declares a template. 
> It doesn't declare an alias.

Yes, but they're different. Again, going to what I said above.

More information about the Digitalmars-d mailing list