Created
June 26, 2012 01:40
-
-
Save Liutos/2992622 to your computer and use it in GitHub Desktop.
The definition of macro ROW->INSTANCE-OF-CLASS
This file contains 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 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)))))) |
This file contains 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 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)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment