On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote:
Maybe I am just too short in D, but I wanted to find out if it is possible to create classes dynamically. My problem is, I just don't know where to start reading. Maybe at mixin templates?

CreateClassWithName!("MyDynamicClassName");

should create the following class to work with dynamically:

class MyDynamicClassName {
    this() { writeln("I was not written, but still I exist!"); }
}

So that I in the end by means of

MyDynamicClassName cls = new MyDynamicClassName;

can work with it.

Normally I would think of a macro first, but as far as I understood D doesn't know macros (which I'm not really sad about), but maybe I'm just thinking too complicated yet. I would appreciate any hints, because as I said, I don't even know where to start reading.

ldc.JIT presumably has smth like that

https://gist.github.com/eldar/2294388

Also look up ldc.dynamic_compile

Reply via email to