On 22/05/2011 16:20, Timon Gehr wrote:
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
Grammar states only that it's syntactically valid, and makes no comment on
semantic validity.
I suspect what Andrej actually meant is to kill treating function signatures as types in
this way. And possibly "enhancement request" rather than "bug".
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"
True, if you use "type" in a broad sense. But it doesn't declare a variable of that type,
and you can't use it as a type as such. Really, function signatures and data types are
distinct entities and ought not to be interchangeable.
alias int func(int); //defines func as type "function that takes int and returns
int"
It is perfectly consistent with other uses of alias.
<snip>
I wouldn't say consistent. The essence of an alias is that you can use it where you would
use what it's an alias of. But in that case, you should be able to do:
alias int func();
func main {
return 0;
}
Stewart.