On Thursday, 15 April 2021 at 16:39:30 UTC, Kagamin wrote:
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;
String mixins is D replacement of macros for code generation.
Works like this:
```d
mixin("class MyDynamicClassName { }");
MyDynamicClassName cls = new MyDynamicClassName;
```
Yes but not at runtime