Guest User

Untitled

a guest
Nov 18th, 2018
76
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'.
  3. The `slots' is a list of symbols. The symbols would be used as both the place
  4. indicator and each would converts to keyword symbol for using in a implicit
  5. MAKE-INSTANCE call."
  6. (let ((_row_ (gensym))
  7. (_class_ (gensym)))
  8. `(let ((,_row_ ,row)
  9. (,_class_ ,class))
  10. (destructuring-bind ,slots ,_row_
  11. (make-instance ,_class_
  12. ,@(mapcan #'(lambda (sym)
  13. `(,(read-from-string
  14. (format nil ":~S" sym))
  15. ,sym))
  16. slots))))))
Add Comment
Please, Sign In to add comment