function is not function
Don Clugston
dac at nospam.com
Wed Sep 26 10:14:20 PDT 2012
On 21/09/12 21:59, Ellery Newcomer wrote:
> solution is to use std.traits, but can someone explain this to me?
>
> import std.stdio;
>
> void main() {
> auto a = {
> writeln("hi");
> };
> pragma(msg, typeof(a)); // void function()
> pragma(msg, is(typeof(a) == delegate)); // nope!
> pragma(msg, is(typeof(a) == function)); // nope!
> }
The 'function' keyword is an ugly wart in the language. In
void function()
'function' means 'function pointer'. But in
is (X == function)
'function' means 'function'.
Which is actually pretty much useless. You always want 'function
pointer'. This is the only case where "function type" still exists in
the language.
More information about the Digitalmars-d-learn
mailing list