I am a common-lisp novice. I am having some troubles with the following macro:
What I have:
Suppose I have a global variable *JAN2018*
which is:
(:NAME "*JAN2018*" :MONTH "Jan" :YEAR 2018 :EXPENSES (:VALUE NIL :TAGS NIL))
If I run
(setf (getf *jan2018* :expenses) '(:value 23 :tags '("a" "b")))
I get for *jan2018*
(:NAME "*JAN2018*" :MONTH "Jan" :YEAR 2018 :EXPENSES
(:VALUE 23 :TAGS '("a" "b")))
The problem:
Now I have the macro:
(defmacro test (sym)
(setf `(getf ,sym :expenses) '(:value 23 :tags '("a" "b"))))
If I run
(test *jan2018*)
I get (using SBCL)
*The function (COMMON-LISP:SETF COMMON-LISP:LIST*) is undefined.
[Condition of type UNDEFINED-FUNCTION]*
What I am trying to do is pass a symbol and update one of its fields. Why I am getting this error, and how can I proceed to update the list?
`(setf (getf ,sym :expenses) '(:value 23 :tags '("a" "b")))
? – melpomene