PocketLang is a lightweight, fast embeddable scripting language. And NimPK is a powerful PocketLang binding for Nim.
https://github.com/khchen/nimpk
This project is still in beta stage, however, I think it is ready to be used and I want some suggestions to complete the documents, examples, and tutorials. So I decide to post this thread. Any recommend is welcome.
Features of NimPK:
- Deep integration. Nim code can access everything in VM (modules, classes, closure, variables, etc).
- Easy-to-use macro to create native modules and classes.
- Bind Nim procedures or code block as closure or method, support overloaded procedure, generic procedure, and varargs parameter.
- Bind any Nim types as native class (set, object, ref, tuple, enum, whatever even char or int).
- Automatic type conversion plus custom type conversion can convert any type between Nim value and script variable.
- Well error handling, catching script error in Nim, or catching Nim exception in script.
Examples and tutorials: https://github.com/khchen/nimpk/tree/main/examples
NimPK use an enhanced version of PocketLang. Enhancements compare to original version:
- String format via modulo operator.
- Optional parameters, and arguments with default values.
- Command like function call.
- Conditional expression.
- Magic methods: _getter, _setter, _call, _dict, etc.
- Iterator protocol.
- RegExp, Timsort, PRNG, etc via new built-in module.
- Error handling.
- Metaprogramming.
- And more...
Demostartion: https://github.com/khchen/pocketlang/blob/devel/tests/devel/demo.pk
NimPK provide an enhanced version of CLI program wrote in Nim. Features of PocketLang CLI:
- Script modules can be imported from a zip archive attached to the main executable, instead of from path (powered by zippy).
- Native modules can be imported from the zip archive, too (powered by memlib, Windows only).
- Builtin zip module.
- Additional builtin functions: echo, args, load.