Inconsistency between `AllMembers` and `hasMember`

Adam D. Ruppe destructionator at gmail.com
Sat Nov 17 22:26:45 UTC 2018


On Saturday, 17 November 2018 at 21:33:37 UTC, drug wrote:
> Another problem I'm trying to resolve is that if I define 
> struct S outside of unittest or inside of unittest but using 
> static qualifier AllMembers does not return "this". Also if 
> struct S do not have methods AllMembers also doesn't return 
> "this". It looks strange for me, but first of all it 
> complicates my code.

That's because the compiler passes it a hidden pointer to refer 
to the context outside. The compiler could perhaps be smarter 
about it, and see if those methods actually refer to the context, 
but it seems to simply say if the method is there, it might refer 
to it and it adds the context pointer (note that S.sizeof 
increases too) and a magic constructor to set it.


More information about the Digitalmars-d-learn mailing list