Bug 3464 – is( void function() == function) is false

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-11-01T15:21:00Z
Last change time
2015-06-09T01:26:55Z
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-11-01T15:21:27Z
pragma(msg, is( void delegate() == delegate).stringof); // true pragma(msg, is( void function() == function).stringof); // false
Comment #1 by bugzilla — 2009-11-02T00:00:05Z
This is apparently intentional. I recently brought up the same issue on the NG: http://www.digitalmars.com/d/archives/digitalmars/D/The_bizarre_world_of_typeof_99461.html#N99486 Quoting Don: "real function()" is a *function pointer*, but is(xxx == function) tests to see if xxx is a *function*, not a *function pointer*.
Comment #2 by dsimcha — 2009-11-09T06:32:47Z
So what is the proper way to test if something is a function pointer then? It seems horribly inconsistent with delegates.
Comment #3 by samukha — 2009-11-09T07:14:01Z
One way to test: is(typeof(*T.init) == function)
Comment #4 by dsimcha — 2010-08-15T21:23:01Z
I'll mark this invalid, since the language lawyers (IANALL) say it is, and the better solution now that it exists is std.traits.isFunctionPointer.