Is it possible to use DMD as a library to compile strings at runtime?
Saurabh Das
saurabh.das at gmail.com
Sun Feb 2 03:16:46 UTC 2020
On Saturday, 1 February 2020 at 20:37:03 UTC, H. S. Teoh wrote:
> On Sat, Feb 01, 2020 at 08:01:34PM +0000, Andre Pany via
> Digitalmars-d-learn wrote: [...]
>> Another approach:
>> - include the dmd compiler package with your application
>> - within your app call the compiler executable and compile the
>> source
>> code to a dll / so
>> - call the dll / so function
> [...]
>
> I've actually done this before in an equation grapher program:
> the user inputs an equation, the program generates D code to
> compute the equation, then runs dmd to compile it into a shared
> library, and opens the shared library and looks up the symbol
> to execute the compiled code. Dmd is fast enough that this
> actually works fairly well. When the input to dmd is small,
> it's so fast you don't even notice it.
>
>
> T
This approach seems more tractable at present. Would you have any
example code lying around for this?
Saurabh
More information about the Digitalmars-d-learn
mailing list