4 ms·
For contrast, gforth (a prominent Forth interpreter, by Forth standards) generates+compiles+links binding code in C, at runtime, using the ordinary C toolchain.
by MaxBarraclough 5y ago
For contrast, gforth (a prominent Forth interpreter, by Forth standards) generates+compiles+links binding code in C, at runtime, using the ordinary C toolchain. [0][1][2]
A bit 'out there' you may say, but on the plus side this approach enables handling header files and tidily expressing bindings without the need to implement their own C parser. [2]
[0] GitHub mirror: https://github.com/forthy42/gforth/blob/dda77d851ddeb80ca849ee554b29ac68fb680a87/libcc.fs#L22 https://github.com/forthy42/gforth/blob/dda77d851ddeb80ca849...
[1] The official host: https://git.savannah.gnu.org/cgit/gforth.git/tree/libcc.fs https://git.savannah.gnu.org/cgit/gforth.git/tree/libcc.fs
[2] https://rosettacode.org/wiki/Call_a_foreign-language_function#Forth https://rosettacode.org/wiki/Call_a_foreign-language_functio...