I think I got most of it to work, but now I'm really confused about the last step, because it's suddenly trying to call keyword arguments as a function (which doesn't work)
This is a piece of the book which explains the workings of the "where", if that's helpful: http://www.gigamonkeys.com/book/practic ... abase.html
And this is what I have now:
Code: Select all
(defun make-modify-expr (field value)
`(setf (getf row ,field) ,value))
(defun make-modify-list (fields)
(loop while fields
collecting (make-modify-expr (pop fields) (pop fields))))
(defmacro update-row (selector-fn &rest clauses)
`#'(lambda (row) (when (funcall ,selector-fn row)
(and ,@(make-modify-list clauses)))))
(defmacro updatem (selector-fn &rest clauses)
`(mapcar
(update-row ,selector-fn ,clauses)
*db* ))
Code: Select all
(updatem (where :rating 6) :rating 7)
Code: Select all
;Compiler warnings :
; In an anonymous lambda form: Undefined function :RATING
I'm hoping anyone could explain to me what is going wrong here. This LISP stuff sounds amazing, but I'm having some trouble trying to understand what is actually happening in some of these functions.