There's a problem with using = and def. I tried it, but many parts of the core and libraries assume a unique namespace. As commands can have many side-effects, everything breaks easily.
Here's a different idea. Suppose that instead we build a basic modulesystem which transforms:
(modules-base
;name of module.
foo
;set of functions in this module
(bar)
;set of module variables
(nitz)
;set of functions from other modules
((module2 hmm niawniaw))
(def bar (x) (hmm) (niawniaw) (do1 nitz (= nitz x))))
(modules-base
foo
(bar)
(nitz)
;gotten by taking (keys module2)
((module2 hmm niawniaw))
(def bar (x) (do1 nitz (= nitz x))))
Weaknesses: (1) we can't make module-variables accessible outside. If we had access to environments, though, we could.
(2) macros are impossible as yet, whether shared or not. Possibly, we need macrolet, and adding some mechanism to store macros separately from the module table - possibly in a table-of-tables module-macros.
Implementation: simple scanning would be nice. However, modules-basic would be better implemented by a 'macrolet form.