Guest User

Untitled

a guest
Nov 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. (defmacro row->instance-of-class (row class &body slots)
  2. "Create an instance of class `class' filled with values extracted from `row'. The `slots' is a list of symbols. The symbols would be used as both the place indicator and each would converts to keyword symbol for using in a implicit MAKE-INSTANCE call."
  3. (let ((_row_ (gensym))
  4. (_class_ (gensym)))
  5. `(let ((,_row_ ,row)
  6. (,_class_ ,class))
  7. (destructuring-bind ,slots ,_row_
  8. (make-instance ,_class_
  9. ,@(mapcan #'(lambda (sym)
  10. `(,(read-from-string
  11. (format nil ":~S" sym))
  12. ,sym))
  13. slots))))))
Add Comment
Please, Sign In to add comment