Last active
November 10, 2016 23:46
-
-
Save spacebat/4ea0ae200c4cb2ce7a8e4a7fd5f4029a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro sq (variable value &optional (documentation nil documentation-p)) | |
"REPL-friendly alternative-to/merger-of setq and defparameter." | |
(assert (and variable (symbolp variable))) | |
(alexandria:once-only (value) | |
`(cond | |
((boundp ',variable) | |
,@(when documentation-p | |
`((setf (documentation ',variable 'variable) ,documentation))) | |
(setf ,variable ,value)) | |
(t | |
(defparameter ,variable ,value ,@(and documentation-p `(,documentation))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment