On Friday, 27 August 2021 at 06:52:10 UTC, Kirill wrote:
Is there a way to do mixin or similar during runtime?
I'm trying to read a csv file and extract data types. Any ideas
on how this should be approached in D are greatly appreciated.
mixin at runtime not possible.
Source code compilation and runing in runtime not possible. But!
But you can impement this!
Steps:
1. Need D compiller
2. In runtime you can compile mixin to dynamic library (.so or
.dll) using external command: `dmd ...`
3. Load dynamic library using `dlopen()` `dlsym()` `dlclose()`.
(on Windows: LoadLibrary(), GetProcAdres(), FreLibrary())
4. Call mixin functions, variables
5. Done!
Packages bindbc-*, derelict-* uses dynamic loading. You can use
both as examples.