typeof(func!0) != typeof(func!0())

Paul Backus snarwin at gmail.com
Mon Aug 22 15:20:46 UTC 2022


On Monday, 22 August 2022 at 14:43:24 UTC, Andrey Zherikov wrote:
> But the question is still opened: why is `typeof(U().func!0)` 
> not the same as `typeof(U().func!0())`?

Probably because if it were the same, it would be completely 
impossible to introspect on the type of `U.func!0` directly. The 
closest you could get would be to examine `typeof(&U.func!0)`; 
i.e., the type of the function pointer rather than the function 
itself.

I'm not totally convinced that the current behavior is the 
correct decision here, but there is a real tradeoff.


More information about the Digitalmars-d-learn mailing list