[CM] wrapper macro strategies

taube heinrich taube@ux1.cso.uiuc.edu
Fri, 25 Jul 2003 22:00:38 -0500 (CDT)


On Fri, 25 Jul 2003, Bret F Battey wrote:

> Oops, sorry, I should have been clearer:
> I already know how to make basic wrapper macros using &body. What I can't crack is
> how to write a macro 'balance-sounds' that could turn this (for example):

do you really need &body statements or can you assume (for example) that the macro
will always balance just two "sound expressions"? if so, then its really simple you
could do something like:

(defmacro balance-sounds (expr1 expr2)
  (let ((var1 (gentemp "temp"))
        (var2 (gentemp "temp")))
    `(sound-let ((,var1 () ,expr1))
        (sound-let ((,var2 () ,expr2))
             (balance ,var1 ,var2)))))

balancing an arbitrary number of sounds is slightly more complex --
one way would be to recursivly iterate the &body
exprs and wrap the results of each recursive iteration in a sound-let.
i could probably cobble  this up but not in Pine where I am typing this
message!