A Swift package and wrapper for the wren scripting language. There is a good QA on wren. It's a very small embeddable language similar to Lua, but w/o the weirdness.
A major thing missing in wren is reentrancy with the host environment. Another issue is that host functions do not get any function environment, i.e. no function specific userdata pointer, or other means which would allow a trampoline. PRs are still welcome, and we'll see where wren is going in the future.
This SwiftPM package embeds Wren itself, i.e. it contains the amalgation in a vendored branch.
The example from the QA:
class Account {
construct new(balance) { _balance = balance }
withdraw(amount) { _balance = _balance - amount }
}
var account = Account.new(1000)
account.withdraw(100)
Hello world:
let vm = WrenVM()
try vm.interpret(
"""
System.print("I'm running in a VM!")
"""
)
Using dynamicCallable:
let vm = WrenVM()
try vm.main.System.print("Hello World!")
swift-wren is brought to you by the Always Right Institute and ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.