3 ms·
For REPL you have three options: - [0] `nim secret` : code is interpreted with Nim's vm. It is limited to compile-time evaluations (e.g. no C/C++ interop). -
by archargelod 3y ago
For REPL you have three options:
- [0] `nim secret` : code is interpreted with Nim's vm. It is limited to compile-time evaluations (e.g. no C/C++ interop).
- [1] `nlvm r` : nlvm backend supports JIT compilation and repl-like interface was added in latest release.
- [2] inim : supports all nim code, but it's not really a true repl. It adds code to a file and recompiles it (you can see the source file with `ctrl+x`). I'd recommend to use it with clang compiler, because it's a bit faster than gcc in my experience. It's the best option right now. And I use it almost daily.
First two options have rudimentary input system. But you can get command history and left-right navigation by wrapping them with rlwrap (should be preinstalled on most *nixes): `rlwrap nim secret`, `rlwrap nlvm r`.
There are plans to support incremental compilation for the next Nim release (it is currently broken). That would improve inim and other repls experience significantly.
[0]: https://nim-lang.org/docs/manual.html#restrictions-on-compileminustime-execution https://nim-lang.org/docs/manual.html#restrictions-on-compil...
[1]: https://forum.nim-lang.org/t/10697 https://forum.nim-lang.org/t/10697
[2]: https://github.com/inim-repl/INim https://github.com/inim-repl/INim