object.factory with template classes for serializing subclasses automatically

Jacob Carlborg doob at me.com
Sun Sep 9 23:32:27 PDT 2012


On 2012-09-10 01:27, timotheecour wrote:
> Is there a way to use Object.factory with template classes?
> eg:
> ----
> class A(T){
>      T x;
> }
> auto a=Object.factory("A!int");
> ----
> Right now this fails (returns null).
>
> Use case:
> If we had this, it would GREATLY simplify serialization (eg as in the
> orange library) by not having to manually register subclasses of a given
> class, eg:
> class B{}
> class C:B{int x;}
> B c=new C;
> right now with orange, we need to register class C before calling
> serialization. If something like Object.factory("A!int") worked, this
> step could be made automatic.

I don't understand how Object.factory could help with serializing. But 
what would help is if we did get proper runtime reflection.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list