Thread overview |
---|
September 22, 2008 [Issue 2369] New: is(T == function) does not recognize function pointers | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2369 Summary: is(T == function) does not recognize function pointers Product: D Version: 2.019 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: snake.scaly@gmail.com Consider the example: template IsFun(T) { static if (is(T == function)) { enum IsFun = T.stringof ~ ": fun"; } else { enum IsFun = T.stringof ~ ": not fun"; } } void foo() {} pragma(msg, IsFun!(typeof(foo))); // (void())(): fun pragma(msg, IsFun!(typeof(&foo))); // void function(): not fun I expect both forms to be detected as functions. -- |
October 04, 2008 [Issue 2369] is(T == function) does not recognize function pointers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2369 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from bugzilla@digitalmars.com 2008-10-04 16:43 ------- But they aren't both functions. One is a function, the other is a pointer to a function. If both were recognized as functions, then one could not distinguish between the two. -- |
October 04, 2008 [Issue 2369] is(T == function) does not recognize function pointers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2369 ------- Comment #2 from snake.scaly@gmail.com 2008-10-04 17:11 ------- The type is called function, you create a value of that type using the function keyword, so I expected the is(T==function) to detect this type. I think the whole is(==) system works strangely. Let's take four cases: void foo() {} class Bar { void bar() {} } Bar b; typeof(foo) // (void())() typeof(&foo) // void function() typeof(b.bar) // (void())() typeof(&b.bar) // void delegate() is(T==function) only true for typeof(foo) is(T==delegate) only true for typeof(&b.bar) is(T:T*) is false for any of them. I'd really like more predictable behavior. -- |
Copyright © 1999-2021 by the D Language Foundation