Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 5354 days ago | link | parent

I think your desired behavior is wrong. You'd like the inner body of a once-only definition to be like this:

  `(let* (($x o$x))
     (+ ,$x 1))
But the macro user would write that body as `(+ ,$x 1), with the backquote and everything, and you don't have that backquote in your hypothetical expansion. What you're probably looking for is:

  `(let* (($x o$x))
     ,`(+ ,$x 1))
Or, more accurately:

  `(let* (($x o$x))
     ,(progn `(+ ,$x 1)))  ; listing all the expressions in the body
Sorry, that's all the time I have to look at it right now. XD

Also, this isn't much of a response to the "generally hard" topic (except to prove this example takes more thought than I've given it so far :-p ).



1 point by akkartik 5354 days ago | link

That is extremely helpful, thanks! I think it's awesome that you can read my ugly code so fast.

Update: Now when I look at it again I notice defmacro! also uses the ,(progn ,@body) trick. Thanks again.

-----