On Mon, 23 May 2011 09:32:47 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:

Steven Schveighoffer wrote:
it's akin to
making:

if(x);

invalid. Yes, it's valid syntax, but it's almost certainly not what the
user wanted.  It's special cased for failure, to aid the developer in
writing less buggy programs.  This would be a similar change, and I
actually thought it was already in the compiler.

It is in the compiler. It is actually not valid syntax anymore (disallowed by
grammar and caught by the parser).

When I said I thought it was already in the compiler, I meant the bizarro function type declaration, not the empty if statement.

And it is not similar to removing function type
alias. You can write if(x){} as a replacement if you need it.

There is currently no alternative for the alias.

But why do you need a function type vs. a function pointer type? Especially since the function pointer type is easily built from the function type, and you can't actually use the function type until you turn it into a function pointer.



I'll throw it back at you, do you see a good use case for it?  And no,
porting C code isn't a good use case.

There are no alias in C code.

I actually gave one:
Timon Gehr wrote:
alias int func();

int main(){
    static assert(is(typeof(main)==func);
    return 0;
}

static assert(is(typeof(&main) == int function());

More straightforward and descriptive.

BTW:

writeln(typeid(int function(int))); //int()*

wtf?

That needs to be fixed, the runtime's TypeInfo.toString methods are not always accurate (I think this warrants a bugzilla report).

-Steve

Reply via email to