Suppose that we have a module foo.Bar:
module foo.Bar
function f = {
return "f()"
}We can invoke f from another module by prefixing it with its module
name:
let r = foo.Bar.f()
Of course, we may also take advantage of an import statement:
module Somewhere.Else
import foo.Bar
function plop = {
return f()
}Imports in Golo do not work as in Java.
Golo is a dynamic language where symbols are being resolved at runtime. Module imports are
not checked at compilation time, and their sole purpose is to help in dynamic resolution. Back
to the previous example, f cannot be resolved from the current module, and the Golo runtime
subsequently tries to resolve f from each import statement. Also, note that the order of
import statements is important, as the resolution stops at the first module having the f
function.
Last but not least, you may prepend the last piece of the module name. The following invocations are equivalent:
module Somewhere.Else
import foo.Bar
function plop = {
let result = f()
let result_bis = Bar.f()
let result_full = foo.Bar.f()
return result
}Golo modules have a set of implicit imports:
gololang.Predefined,
gololang.StandardAugmentations,
gololang,
java.lang.