Edward Dodge <nospam@noreply.com> wrote:
+---------------
| ...why not call the macro once, with three parameters?
| (enclosingfunction (macro "parameter1" "parameter2" "parameter3"))
| The problem now is this: how to getthe macro to return multiple
| parameters and splice them into the enclosing form?
+---------------
You can't do exactly that, since no form can reach "outside" itself.[1]
Instead, you would need your macro to take the "enclosingfunction"
as an argument [now no longer "enclosing" per se] along with the
additional parameters to be modified/passed, e.g.:
(defmacro your-macro (function-name &rest forms)
`(,function-name ,@(mapcar #'your-transformer-function forms)))
Where YOUR-TRANSFORMER-FUNCTION is some ordinary function
of one s-expr, argument that returns one s-expr.
For example:
> (defmacro funcall-with-incremented-args (function-name &rest forms)
(flet ((transformer (x) `(1+ ,x)))
`(,function-name ,@(mapcar #'transformer forms))))
FUNCALL-WITH-INCREMENTED-ARGS
> (* 2 3 4)
24
> (funcall-with-incremented-args * 2 3 4)
60
> (macroexpand '(funcall-with-incremented-args * 2 3 4))
(* (1+ 2) (1+ 3) (1+ 4))
T
>
-Rob
[1] Except perhaps by emitting references to free variables,
usually a dangerous practice, but that's another story...
Or by playing games with the macro &ENVIRONMENT, and
that's a *whole* 'nother story!!
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607