actual working code...
module SomeFunctions
function bar = |somethingWithV, a, b| -> somethingWithV: v() + a + b
module SomeTypes
struct Foo = {v}
function foo = |aFoo, a, b, x| -> aFoo: bar(a, b) + " " + x
&augmentWithFunctions(SomeTypes.types.Foo.class, ^SomeFunctions::bar, ^foo)
module Test
import SomeTypes
function main = |args| {
let f = Foo(1)
println(f: foo(2, 3, ":)"))
}
$ golo golo --files functions.golo types.golo test.golo
6 :)
The macro actually expand to
augment SomeTypes.types.Foo {
function foo = |this, args...| -> ^foo: bindTo(this): invoke(args)
function bar = |this, args...| -> ^SomeFunctions::bar: bindTo(this): invoke(args)
}
🆒