July 31, 2022 Interfacing with user-supplied binary or obj file | ||||
---|---|---|---|---|
| ||||
So I'm making an interpreter for my custom scripting language and I want to allow users to write libraries in languages other than said scripting language (for efficiency). For example, you should be able to write a mathematics library in D, compile it, then write a simple wrapper in my language and then be able to import it to your script to use (similar to a lot of Python libraries). So how exactly could I do this without requiring to user to recompile the interpreter every time they want to use a new library? Is there some way I could dynamically link in compiled .obj files? |
July 31, 2022 Re: Interfacing with user-supplied binary or obj file | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheZipCreator | On Sunday, 31 July 2022 at 10:55:58 UTC, TheZipCreator wrote:
> So I'm making an interpreter for my custom scripting language and I want to allow users to write libraries in languages other than said scripting language (for efficiency). For example, you should be able to write a mathematics library in D, compile it, then write a simple wrapper in my language and then be able to import it to your script to use (similar to a lot of Python libraries). So how exactly could I do this without requiring to user to recompile the interpreter every time they want to use a new library? Is there some way I could dynamically link in compiled .obj files?
Dynamically linking .obj files is basically wrapping all together to a shared library, loaded at runtime. So you need an interface that interops with your script language that must provide options to exchange input/output, registering functions that are callable from your script while your library is loaded and such stuff. The final logic is up to you.
|
Copyright © 1999-2021 by the D Language Foundation