1

A particular macro runs each expression in its body, interleaving an atom between each expression, and collecting the results.

This works well with hard-coded expressions, but if I want to dynamically generate a series of expressions to be inserted in the body of the macro call, that won't work, obviously, because that will be evaluated after the macro has done its job.

I suppose the solution is to write my own macro to generate the expressions I need, but I'm not sure that will be evaluated before the outer macro.

I tried something like this, but it didn't work:

(mac genexpr (list)
  (map (fn (e) `(something ,e)) list))
Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Pedro Silva
  • 4,672
  • 1
  • 19
  • 31
  • 4
    Do you have some example inputs, as well as expected outputs? It's hard to see what you're trying to do in precise terms. – C. K. Young Aug 19 '11 at 02:17

1 Answers1

6

Try using a begin (scheme) or progn (common lisp) form. It looks like you're using arc, which appears to name this construct do.

(mac genexpr (list)
  `(do ,@(map (fn (c) `(something ,e)) list)))
Aaron
  • 3,454
  • 23
  • 26