Thread overview | |||||
---|---|---|---|---|---|
|
March 30, 2018 dynamically compile and load glue logic | ||||
---|---|---|---|---|
| ||||
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? especially the 2nd point is important as i would want to load 100's of those snippets. For the context: the idea is to create a streaming-ETL system where you can dynamically add/remove rules/modules. it would be great if logic could be written directly in D and operate on specific (library provided) objects. |
March 30, 2018 Re: dynamically compile and load glue logic | ||||
---|---|---|---|---|
| ||||
Posted in reply to yawniek | 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... |
March 31, 2018 Re: dynamically compile and load glue logic | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 31/03/2018 3:38 AM, H. S. Teoh wrote:
> 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.)
Still need to, front end is barely alpha.
Can't be reset for example (last I checked, but doubt that has changed).
|
Copyright © 1999-2021 by the D Language Foundation