On Tuesday, 8 September 2015 at 19:30:16 UTC, chris stevens wrote:
On Sunday, 6 September 2015 at 14:45:45 UTC, BBasile wrote:
You have Object.factory for this. You can also use a custom factory based on string comparison. (with some: static if(condition) return new This; else static if(otherCondition) return new That; etc).

I just had a look at Object.factory and this isn't actually what I wanted. I was looking for something that would allow me to create new (previously undefined) classes in D at runtime that I could then use with Object.factory to create instances of.

I think I can do this with Variants and dynamic, is this possible? Or is there another way?

"Previously undefined". As far as I know, this is impossible in D. Thr compiler has to know how much memory to allocate/request and it has to know that at compiletime (else it wouldn't be the compiler!)

This functionality in Java/C# is possible because it's running on a vm that allows special instructions to make the vm compile and make available a class dynamically (and by extension, slowly)

Reply via email to