It turns out there’s a rather simple solution:
Generate a module containing a noop function for each function you want to have namespaced, then afterwards add methods to these functions (using fully qualified names).
So, as a mockup example:
@genmodule AName
would produce:
module AName
function fun1() end
function fun2() end
end
function AName.fun1(x)
# do something relevant
end
function AName.fun2(y)
# do something else
end
Where fun1(x) and fun2(y) have full access to the outer namespace but can only be called via AName.