[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Defining a Macro
I am trying to define a macro to construct expressions like
'(fcn-1 [arg1-val [arg2-val]])
where arg1-val and arg2-val are (the values of) the arguments of the macro.
I think, the usual way to do it is defining a macro like
(defmacro BUILD-MY-EXPRESSION (arg1 arg2)
`'(fcn-1 [,arg1 [,arg2]]))
But that doesn't work: the evaluation of the form
(BUILD-MY-EXPRESSION 'test1 'test2) returns (FCN-1 [,ARG1 [,ARG2]]) instead of
(FCN-1 [TEST1 [TEST2]]).
I suppose it is due to the fact that #\[ is a macro-character associated to a
specific function. If so, is there a way to use it locally as a usual char?
Reformulation of the problem:
I would like to define a macro that returns the same expression as the function
defined below:
(defun BUILD-MY-EXPRESSION (arg1 arg2)
(let ((my-expr
(format nil "(fcn-1 [~a [~a]])"arg1 arg2)))
my-expr))
Any clue ?
I'll be grateful on any help.
Thanks in advance.
--akd.