DIP 45 - approval discussion
deadalnix
deadalnix at gmail.com
Wed Nov 13 14:25:52 PST 2013
On Wednesday, 13 November 2013 at 08:48:09 UTC, Jacob Carlborg
wrote:
> On 2013-11-13 01:36, deadalnix wrote:
>
>> The serialization is a good example. You'll have to note that
>> if the
>> code has been able to serialize the data, it can generate at
>> compile
>> time the necessary scafolding to deserialize it.
>
> No, not necessarily. If you serialize an object through a base
> class reference you currently need to register that with the
> serializer. The static type information is lost and D doesn't
> provide enough runtime reflection to get the values of instance
> variables of an object at runtime.
OK, I see your problem here.
It is a much more general problem than the one solved by the
factory. For instance, I wanted in the past to write some
unittest that ensure Liskov's substitution principle (so run the
unittest on subclasses).
This is fundamentally the same issue : you want to write some
code that is aware of subclasses. That require somehow to be able
to mixin something automatically in all subclasses.
Object.factory only solve poorly one instance of this problem.
More information about the Digitalmars-d
mailing list