Compiler patch for runtime reflection

Kapps Kapps at NotValidEmail.com
Tue Oct 25 23:05:51 PDT 2011


The point of runtime reflection is not your own code, that's the thing.
By having opt-in reflection, you are at the mercy that every single 
component, every piece of code, every library, that you did not write, 
the author decided to enable reflection. It is an unreasonable assumption.


On 25/10/2011 11:44 PM, Robert Jacques wrote:
> I understand that at times when serialization has to break
> encapsulation. My opinion though, is that classes should have to opt in,
> before the serializer goes ahead and breaks their carefully designed
> encapsulation. i.e. someone should have to code review the class to make
> sure everything is kosher. For code you are developing, this is as
> simple and straightforward as adding a single mixin statement to the class.

It is the responsibility of the one using your code to determine whether 
they want take the risk and access private members.
Sometimes, it's needed. I have used private methods in production code 
when programming in .NET, just because the developers of it did not 
realize that something that's private would be useful to some people. It 
saved many, many, hours of pain and effort of rolling your own solution. 
If I upgrade the app to a newer version of .NET and the code breaks, 
that's the risk that was taken. Presumably the person accessing these 
things the author did not intend has taken steps to ensure it doesn't 
break if things change (or doesn't intend to link to a newer version of 
the library).


More information about the Digitalmars-d mailing list