Skip to content

Instantly share code, notes, and snippets.

@lukego
Created September 19, 2021 10:24
Show Gist options
  • Select an option

  • Save lukego/830a787776b93d2cf9ff8fc6304598ce to your computer and use it in GitHub Desktop.

Select an option

Save lukego/830a787776b93d2cf9ff8fc6304598ce to your computer and use it in GitHub Desktop.
(defmacro def.wrapper (f args)
"Make (.F ARGS...) a double-float version of (F ARGS...)."
(flet ((coercer (x) `(coerce ,x 'double-float)))
`(defun ,(symbolicate "." f) ,args
,(coercer `(,f ,@(mapcar #'coercer args))))))
(def.wrapper + (x y))
==>
(DEFUN .+ (X Y)
(COERCE (+ (COERCE X 'DOUBLE-FLOAT) (COERCE Y 'DOUBLE-FLOAT)) 'DOUBLE-FLOAT))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment