Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
Created September 11, 2014 17:13
Show Gist options
  • Save rentalcustard/5a6181c4de9a49e3204b to your computer and use it in GitHub Desktop.
Save rentalcustard/5a6181c4de9a49e3204b to your computer and use it in GitHub Desktop.
(defmacro new-if [pred then-clause else-clause]
`(cond ~pred ~then-clause
:else ~else-clause))
"This works, in that if I call it like so:
"
(new-if (= 2 3) (while true (print "hi")) :bye)
"I don't get an infinite loop, but I don't understand how. I've unquoted everything in the macro body, so shouldn't the normal evaluation order apply? Why doesn't it evaluate then-clause when I do it this way?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment