Skip to content

Instantly share code, notes, and snippets.

@spacebat
Created September 13, 2016 00:56
Show Gist options
  • Select an option

  • Save spacebat/4f0c6b0fd30b534671eed3946954fb99 to your computer and use it in GitHub Desktop.

Select an option

Save spacebat/4f0c6b0fd30b534671eed3946954fb99 to your computer and use it in GitHub Desktop.
Clojure's definline in CL
(defmacro definline (name args &body body)
`(progn
(defmacro ,name ,args ,@body)
(setf ,name (lambda ,args (,name ,@args)))))
CL-USER> (definline myor (a b) `(or ,a ,b))
#<anonymous interpreted function 40500011FC>
CL-USER> (myor t (error "boom!"))
T
CL-USER> (apply myor '(nil t))
T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment