On Tuesday, 11 September 2012 at 04:47:11 UTC, timotheecour wrote:
Also, now that I think about it, why couldn't you do this? (it's equivalent):

auto serialize(T)(T a) {
   auto c = cast(SerializerBase) new Serializer!T;
   return c.serialize(a);
}

that won't work with my example:
class A{}
class B:A{int x;}
A a=new B;
auto c=serialize(a); => T is A, but we want B so that serialization includes field x.

Ah, I see now.

Well regardless, it couldn't be done so conveniently/transparently because Serializable!B wouldn't exist in the binary unless it was actually created in code.

Reply via email to