Hi,
I have a macro that creates a clausure like this:
Code: Select all
(defmacro object-mult (atr1 atr2)
` (let ((atr1 ,atr2) (atr2 ,atr2))
(lambda (x) (* atr1 atr2))))
The thing is that I'm trying to implement another macro that automatically produces the code shown in the example above . The macro skeleton would be something like:
Code: Select all
(defmacro generate-class (name attributes code)
`(defmacro ,name (,@attributes)
(let ...)))
This way, I could call "generate-class" with the arguments atr1, atr2 and '(* atr1 atr2) and the macro will expand to what is shown in the first example. The problem is that I don't know how to specify the "comma" operators inside "generate-class" to obtain the symbols ",atr1" and ",atr2" in the let part in "object-mult". I came up with a solution consisting in transforming the symbols into strings and then inserting the "," at the beginning of the string. Then I had to obtain a valid symbol from the string by calling (intern ...). I know how to get a proper keyword symbol from a string using "KEYWORD" as the second argument to intern. Is there something similar for strings starting with ","?
Thanks in advance,
Luis