Skip to content

Instantly share code, notes, and snippets.

@spacebat
Last active November 10, 2016 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacebat/4ea0ae200c4cb2ce7a8e4a7fd5f4029a to your computer and use it in GitHub Desktop.
Save spacebat/4ea0ae200c4cb2ce7a8e4a7fd5f4029a to your computer and use it in GitHub Desktop.
(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