You may also take advantage of the predefined fun function to obtain a reference to a closure, as
in:
import golotest.Closures
local function local_fun = |x| -> x + 1
function call_local_fun = {
# local_fun, with a parameter
var f = fun("local_fun", golotest.Closures.module, 1)
# ...or just like this if there is only 1 local_fun definition
f = fun("local_fun", golotest.Closures.module)
return f(1)
}Last but not least, we have an even shorter notation if function are not overridden:
import golotest.Closures
local function local_fun = |x| -> x + 1
function call_local_fun = {
# In the current module
var f = ^local_fun
# ...or with a full module name
f = ^golotest.Closures::local_fun
return f(1)
}