What is this strange alias syntax?

Timon Gehr timon.gehr at gmx.ch
Sun May 22 08:20:15 PDT 2011


Andrej Mitrovic wrote:
> Should I file a bug report to kill this syntax?

No. It is perfectly valid, see grammar:
http://www.digitalmars.com/d/2.0/declaration.html

What is strange about this syntax in particular?

int i; //declares i of type "int"
alias int i; //defines i as type "int"

int func(int); //declares func of type "function that takes int and returns int"
alias int func(int); //defines func as type "function that takes int and returns int"

It is perfectly consistent with other uses of alias. It is the way alias works
(taken from typedef), and function declarations work (also taken from c) that are
somewhat strange, not this particular case.

Timon


More information about the Digitalmars-d-learn mailing list