0
votes
(defmacro foo (x)
    `(defun ,xt ()
         (format t "hullo")))

(foo bar)

will not define a function bart, since ,xt is read as the variable xt rather than the variable x plus a t. But is there a way to get a function bart by supplying the argument bar?

1

1 Answers

3
votes

You need to create the function name (which is a string then) and then convert it to a symbol, for example:

(defmacro foo (x)
  `(defun ,(intern (format nil "~aT" x)) ()
     (format t "hullo")))

then

? (foo bar)
BART
? (bart)
hullo
NIL