This is not my “production code," but a simplification of the problem for illustration. Also, the title of this question is misleading, as it recalls the ~ @ extension, which I understand, and which might not be a problem. Please suggest a better question title if you can.
Given a macro like this:
(defmacro my-add [x & ys] `(+ ~x ~@ys ))
Now let's say that we have a list:
(def my-lst '(2 3))
Now I want a function that uses my-add so that I can pass my-lst as arg, i.e.
(call-my-add 1 my-lst)
I define a function in what seems obvious:
(defn call-my-add [x ys] (apply my-add (cons x ys)))
But:
java.lang.Exception: Can't take value of a macro: #'user/call-my-add (repl-1:60)
I tried all kinds of wild tricks to make the call-my-add function work using evaluations, applying and even defining call-my-add as a macro, but they all give similar ClassCastExceptions.
Is there a way out of this?
source share