I wrote: > * Also note that the real `current-module' simply accesses a fluid, > which can also be set by `set-current-module'. (Fluids are a scheme > analogue to "dynamically-scoped" variables in Lisp). Conceptually, it > is variable that is explicitly set by the user. It has no relation to > the code that is currently executing. Rather, it is used during > compilation (or within a REPL) to keep track of where the user would > like top-level definitions to go.
That last bit was not quite right, let me try again: The `current-module' is used during compilation, within a REPL, or by primitive-eval, to keep track of which module the user would like top-level forms to be compiled in. It is set at compile time by constructs such as `define-module' or (eval-when (compile) (set-current-module <module>)), and this module is baked into every identifier at compile time before macro processing takes place. Macros in general might slice and dice and mix together fragments of code from many different modules. When this jumble of macro-expanded code is evaluated, (current-module) is no longer relevant to it. Instead, each top-level variable reference uses the module that was baked into its identifier before macro expansion. Mark