You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to reach more platforms such as WASM or micro controllers, it would be nice to move away from the current implementation which relies on {e}println and the standard library's file reading abstraction. Instead, we should focus some of our efforts on adding two traits (with a default implementation) which would allow the interpreter to run on other platforms provided they implement that trait.
The ideal API for "libjinko" users (such as the interpreter) would be something like that:
- let mut ctx = Context::new();+ let mut ctx = Context::<DefaultReader, WasmWriter>::new();
Add a Reader/Input trait
Add a method to read a file
Add a method to read a string
In the case of platforms without a file system, or where interactive user input is not possible, the trait could have default implementations for these methods in order to not burden someone using libjinko.
Add a Writer/Output trait
Add a method to write to an equivalent of stdout
Add a method to write to an equivalent of stderr
Add default StdWriter and StdReader types which implement Writer and Reader using existing stdlib functions, such as fs::read_to_string, println!(), eprintln!()
Remove reading/writing without the trait throughout the jinko library
In the Incl instruction, files are read and parsed through fs::read_to_string()
Errors are emitted using eprintln!()
The parser reads a file using fs::read_to_string
There might be other places where this is the case
Ideally, this should allow us to compile the jinko library in a no_std + alloc environment. We could think about developing a tiny no_std repl example to test this.
We should not bother about FFI at this point, even though this issue clearly targets platforms where libffi might not be available.
The text was updated successfully, but these errors were encountered:
In order to reach more platforms such as WASM or micro controllers, it would be nice to move away from the current implementation which relies on
{e}println
and the standard library's file reading abstraction. Instead, we should focus some of our efforts on adding two traits (with a default implementation) which would allow the interpreter to run on other platforms provided they implement that trait.The ideal API for "libjinko" users (such as the interpreter) would be something like that:
Reader
/Input
traitIn the case of platforms without a file system, or where interactive user input is not possible, the trait could have default implementations for these methods in order to not burden someone using libjinko.
Add a
Writer
/Output
traitstdout
stderr
Add default
StdWriter
andStdReader
types which implementWriter
andReader
using existing stdlib functions, such asfs::read_to_string
,println!()
,eprintln!()
Remove reading/writing without the trait throughout the jinko library
Incl
instruction, files are read and parsed throughfs::read_to_string()
Error
s are emitted usingeprintln!()
fs::read_to_string
Ideally, this should allow us to compile the jinko library in a no_std + alloc environment. We could think about developing a tiny no_std repl example to test this.
We should not bother about FFI at this point, even though this issue clearly targets platforms where libffi might not be available.
The text was updated successfully, but these errors were encountered: