I want to use a macro to define variables. However, evaluating the macro does not define these vars. I seem to be missing something, but I can't find it. Here's the code:
(defmacro delve--build-cmp (name desc sort-fn-asc sort-fn-desc slot-fn &optional map-fn) "Define two comperator functions based on NAME." (declare (indent 1)) (let* ((name-as-string (format "%s" name)) (name-asc (make-symbol (concat name-as-string "-asc"))) (name-desc (make-symbol (concat name-as-string "-desc"))) (desc-asc (concat desc ", ascending order.")) (desc-desc (concat desc ", descending order."))) `(progn (defvar ,name-asc (delve-cmp--create :comp (delve--cmp-fn ,sort-fn-asc ,slot-fn ,map-fn) :desc ,desc-asc) ,desc-asc) (defvar ,name-desc (delve-cmp--create :comp (delve--cmp-fn ,sort-fn-desc ,slot-fn ,map-fn) :desc ,desc-desc) ,desc-desc))))
delve-cmp--create is a function which defines a structure object, so nothing special there. All I want is to define these two objects at the time of the evaluation of the macro. I thought about using functions, but I like it that we can use unevaluated symbol names in macros which spares us the need to quote the name. In the end, I would like to have some kind of
So my question is: What is wrong with this code, why isn't the defvar eval'ed when I eval a call to that macro?