Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro row->instance-of-class (row class &body slots)
- "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."
- (let ((_row_ (gensym))
- (_class_ (gensym)))
- `(let ((,_row_ ,row)
- (,_class_ ,class))
- (destructuring-bind ,slots ,_row_
- (make-instance ,_class_
- ,@(mapcan #'(lambda (sym)
- `(,(read-from-string
- (format nil ":~S" sym))
- ,sym))
- slots))))))
Add Comment
Please, Sign In to add comment