Open dumblob opened 3 years ago
Any plans to have first-class support for compile-time FFI (e.g. to C functions & structs)?
If this requires a toolchain to achieve, No. Pocketlang is and will always be standalone, and I'm afraid this might break the "Easily embeddible" nature.
Any pointers on how to do this without breaking the "simplicity" of pocketlang is wellcome.
I'm not sure what you mean with "toolchain". Pocketlang seems to be 100% dependent on the Wren "toolchain" - so why not to allow FFI into Wren ecosystem? And if Wren already has FFI to e.g. C ecosystem, why not to use it as well?
When I say toolchain I meant something like assembler and linker (like LLVM does), that cannot be integrated.
Pocketlang seems to be 100% dependent on the Wren
No, the phrase "The language is written using Wren Language and their wonderful book Crafting Interpreters as a reference." might confuse you, but pocketlang is written in pure C99 and it doesn't rely on wen. And wren doesn't support FFI (as for now).
https://github.com/libffi/libffi Seems promising and easy to integrate. Many mainstream languages are using it (python, ruby ffi, java openjdk, mozilla javascript).
@dumblob
Thanks for clarification! Yes, I got confused by the sentence you quoted (maybe this could be clarified in the readme?).
Regarding the need for a "toolchain" it's kind of implied by FFI itself. So I'm afraid if FFI should become a thing, then a "toolchain" is inevitable.
A seamless minimal FFI could look like this: https://slightknack.dev/blog/ffi-hard/ .
Any plans to have first-class support for compile-time FFI (e.g. to C functions & structs)?
Or more generally - any plans to stand on the shoulders of some of the huge existing language ecosystems (C, Python, C++, Ruby, Rust, Java, ...)?
With compile-time I mean to not need to manually generate (or worse write) bindings, but use some language feature (e.g. special syntax like prefix
C.
resulting inC.printf( "%s%d", ... )
).