Just a POC on a discussion we had with @Artpej
Given
module MyMod
function foo = |a, b| -> a + b
function bar = -> println("MyMod.bar")
we can do
module Test
function Module = |mod| -> DynamicObject()
: fallback(|this, name, args...| -> fun(name, mod, args: length()): invoke(args))
function main = |args| {
let m = Module(MyMod.module)
println(m: foo(1, 2))
m: bar()
}
or if you rather struct
and augment
struct Module = { mod }
augment Module {
function fallback = |this, name, args...| ->
fun(name, this: mod(), args: length()): invoke(args)
}
π
Excellent! π