diff --git a/Code/clostrum.lisp b/Code/clostrum.lisp index 66a277a..af94706 100644 --- a/Code/clostrum.lisp +++ b/Code/clostrum.lisp @@ -57,7 +57,8 @@ (define-accessor env:symbol-value (client environment variable-name)) (defgeneric env:boundp (client env variable-name)) (defgeneric env:makunbound (client env variable-name)) -(defgeneric env:make-variable (client environment variable-name value)) +(defgeneric env:make-variable (client environment variable-name + &optional value)) (defgeneric env:make-parameter (client environment variable-name value)) (defgeneric env:make-constant (client environment variable-name value)) (defgeneric env:make-symbol-macro (client environment variable-name expansion)) diff --git a/Code/default-methods.lisp b/Code/default-methods.lisp index 5c91039..7e18d79 100644 --- a/Code/default-methods.lisp +++ b/Code/default-methods.lisp @@ -83,18 +83,20 @@ (sys:variable-cell-makunbound client (sys:variable-cell client environment variable-name))) -(defmethod env:make-variable (client environment variable-name new) +(defmethod env:make-variable (client environment variable-name + &optional (value nil valuep)) (ecase (sys:variable-status client environment variable-name) ((nil) - (setf (sys:variable-cell-value - client (sys:variable-cell client environment variable-name)) - new - (sys:variable-status client environment variable-name) - :special)) + (when valuep + (setf (sys:variable-cell-value + client (sys:variable-cell client environment variable-name)) + value)) + (setf (sys:variable-status client environment variable-name) :special)) ((:special) - (let ((cell (sys:variable-cell client environment variable-name))) - (unless (sys:variable-cell-boundp client cell) - (setf (sys:variable-cell-value client cell) new)))) + (when valuep + (let ((cell (sys:variable-cell client environment variable-name))) + (unless (sys:variable-cell-boundp client cell) + (setf (sys:variable-cell-value client cell) value))))) ((:constant) (error 'env:attempt-to-define-special-variable-for-existing-constant :name variable-name)) diff --git a/Code/documentation.lisp b/Code/documentation.lisp index 2ffe6dd..4d6ff4e 100644 --- a/Code/documentation.lisp +++ b/Code/documentation.lisp @@ -143,7 +143,7 @@ The nature of a setf expander is otherwise implementation-defined. One choice wo (function env:makunbound "As CL:MAKUNBOUND. Make VARIABLE-NAME have no global value in ENVIRONMENT. Returns VARIABLE-NAME.") (function env:make-variable - "Functional version of CL:DEFVAR. Proclaim VARIABLE-NAME special, and if it has no global value, set its global value to VALUE.") + "Functional version of CL:DEFVAR. Proclaim VARIABLE-NAME special, and if it has no global value and VALUE is provided, set its global value to VALUE.") (function env:make-parameter "Functional version of CL:DEFPARAMETER. Proclaim VARiABLE-NAME special, and set its global value to VALUE.") (function env:make-constant