On Sun, 07 Dec 2014 21:44:51 +0000 bitwise via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> I would like to be able to reflect private members though... Is > there any way to give a module private access to an unrelated > module? nope. and i hope there will be no such thing. ;-) > I understand that packages are meant to solve this problem for > regular code, but given the fact that D has such a comprehensive > reflection system, it would be nice to have this special case. you either want to inspect something from the outside and then it's not private, or it's private and invisible to the strangers. by introducing hacks you killing the protection idiom altogether. if you need to modify the module you want to inspect to insert pragma... well, make the necessary things 'package'-protected and and inspector to the package: you modified the module anyway. if you want to allow external pragmas that allows poking private module data... well, just make everything in that module public, you just killed the whole protection thing. ;-) what i really want to say is that if you need to even know about private members from the outside of the module, something is very-very wrong. dump the idea that reflection can do at least *something* with private parts. that's bad. that's dangerous. that's dirty. *nobody* can know anything about object internals except the object and his close friends living in the same module. either don't make it private or pretend that it's non-existant for the outside world.
signature.asc
Description: PGP signature