lang: Refactor most functions to support modules

This is a giant refactor to move functions into a hierarchial module
layout. While this isn't entirely implemented yet, it should work
correctly once all the import bits have landed. What's broken at the
moment is the template function, which currently doesn't understand the
period separator.
This commit is contained in:
James Shubin
2018-11-10 22:19:28 -05:00
parent c32183eb70
commit 046b21b907
55 changed files with 400 additions and 106 deletions

View File

@@ -62,6 +62,12 @@ func Register(name string, fns []*types.FuncValue) {
funcs.Register(name, func() interfaces.Func { return &simplePolyFunc{Fns: fns} })
}
// ModuleRegister is exactly like Register, except that it registers within a
// named module. This is a helper function.
func ModuleRegister(module, name string, fns []*types.FuncValue) {
Register(module+funcs.ModuleSep+name, fns)
}
// simplePolyFunc is a scaffolding function struct which fulfills the
// boiler-plate for the function API, but that can run a very simple, static,
// pure, polymorphic function.