On 2012-09-11 07:57, Chris Cain wrote:
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.
Hence proper runtime reflection is needed. I see no way out of this.
--
/Jacob
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{}
c
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
On Tuesday, 11 September 2012 at 03:18:40 UTC, timotheecour wrote:
auto serialize(T)(T a){
auto
c=cast(SerializerBase)Object.factory("Serializer!("~typeid(a).to!string~").Serializer");
return c.serialize(a);
}
Also, now that I think about it, why couldn't you do this? (it's
equivalen
On Tuesday, 11 September 2012 at 03:18:40 UTC, timotheecour wrote:
So the question is: is that technically impossible or not to
enhance Object.factory in such ways?
Unless someone else wants to correct me, I'm going to say
technically impossible. Object.factory constructs a class at
runtime giv
I don't understand how Object.factory could help with
serializing. But what would help is if we did get proper
runtime reflection.
All that'd be needed would be to have Object.factory working with
templates, here's how:
unittest{
class A{}
class B{int x;}
A a=new B;
auto
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 l
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