On Fri, Mar 30, 2018 at 02:24:45PM +0000, yawniek via Digitalmars-d-learn wrote: > in how far is it or would the following be possible: > > dynamically compile and execute some glue logic that is also written > in D under linux? > > and what happens if that code uses phobos or other dub libs that are > available in the host binary? [...]
I've written a program where user input drives the generation of a code snippet that then gets passed to an invocation of dmd, compiled, linked and the loaded as a shared library via dlopen(), et al. It works fairly well, and dmd generally is fast enough that the pause is not very noticeable. (This was before dmd-as-a-library was available; I imagine it would be even faster today now that you don't have to spawn a separate dmd process.) The generated snippet does import std.math, and it seems to work fine. But then the generated snippets tend to be fairly small, and only use a limited subset of the language, so there may be gotchas that I'm not aware of. T -- Don't throw out the baby with the bathwater. Use your hands...