digitalmars.D.bugs - [Issue 2369] New: is(T == function) does not recognize function pointers
- d-bugmail puremagic.com (26/26) Sep 21 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2369
- d-bugmail puremagic.com (11/11) Oct 04 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2369
- d-bugmail puremagic.com (17/17) Oct 04 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2369
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. --
Sep 21 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2369 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 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. --
Oct 04 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2369 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. --
Oct 04 2008