typeof()

Steven Schveighoffer schveiguy at yahoo.com
Fri Oct 21 08:19:31 PDT 2011


On Fri, 21 Oct 2011 10:54:47 -0400, Jacob Carlborg <doob at me.com> wrote:

> On 2011-10-21 16:17, Steven Schveighoffer wrote:

>> This can still be done. If you have the compile-time type you can always
>> forcefully generate the run time info (I would expect such a feature
>> when RTTI is fully developed).
>
> The thing is that you may not have access to the compile-time type, i.e.  
> :
>
> class Base {}
> class Sub : Base {}
>
> Base sub = new Sub;
>
> Now the compile-time information specific for Sub is gone when accessing  
> "sub".
>
> I have this problem with my serialization library. To workaround this  
> the user have to register the compile-time type with the serializer to  
> be able to (de)serialize via base class references.

Well, .NET requires you to put an attribute on a class to allow it to be  
serializable.  And that doesn't seem to get in the way of .NET code that  
uses serialization.

-Steve


More information about the Digitalmars-d mailing list