Created
August 27, 2019 23:17
-
-
Save slyrus/5c558d268248c7935c25d50f985a9416 to your computer and use it in GitHub Desktop.
with-assoc
This file contains hidden or 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 with-assoc (associations object &body body) | |
| (let ((obj (gensym))) | |
| `(let ((,obj ,object)) | |
| (declare (ignorable ,obj)) | |
| (symbol-macrolet | |
| ,(mapcar (lambda (association-entry) | |
| (destructuring-bind (assoc-name var-name) | |
| association-entry | |
| `(,var-name (cdr (assoc ,assoc-name ,obj))))) | |
| associations) | |
| ,@body)))) |
Bike
commented
Aug 27, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment