`((setf (documentation ',name 'variable) ,documentation)))
(add-module-binding ',name (lambda () ,value-form))))
-(export 'call-with-module-environment)
-(defun call-with-module-environment (thunk)
- "Invoke THUNK with a new collection of bindings for the module variables."
- (progv
- (mapcar #'car *module-bindings-alist*)
- (mapcar (compose #'cdr #'funcall) *module-bindings-alist*)
- (funcall thunk)))
+(export 'with-module-environment)
+(defmacro with-module-environment ((&optional (module '*module*)) &body body)
+ "Evaluate the BODY with MODULE's variable bindings in scope."
+ `(call-with-module-environment (lambda () ,@body) ,module))
;;;--------------------------------------------------------------------------
;;; The reset switch.
(items :initarg :items :initform nil :type list :accessor module-items)
(dependencies :initarg :dependencies :initform nil
:type list :accessor module-dependencies)
+ (variables :initarg :variables :type list :accessor module-variables
+ :initform (mapcar (compose #'cdr #'funcall)
+ *module-bindings-alist*))
(state :initarg :state :initform nil :accessor module-state))
(:documentation
"A module is a container for the definitions made in a source file.
* A list of other modules that this one depends on.
+ * A list of module-variable values, in the order in which they're named
+ in `*module-bindings-alist*'.
+
Modules are usually constructed by the `read-module' function, though
there's nothing to stop fancy extensions building modules
programmatically."))