What's important though is that the expressions received by the compiler contain a mixture of user- and macro-written code. For example, given the following hygienic OR macro:
(define-syntax or (form1 form2)The code
`(let ((tmp ,form1))
(or foo bar)is translated to:
(let ((tmp foo))The blue parts are user-written, the white parts are macro-written.
The important thing is that parts with different colors do not interact.
So even if we use the variable name TMP, the code still works as expected because a white TMP doesn't interact with a blue TMP.
(or foo tmp)is translated to:
(let ((tmp foo))Without the colors, the code would always return the value of FOO.
This is one part of the equation: the macro-written white TMP doesn't shadow the user-written blue TMP.
The other part is that user-written code mustn't shadow macro-written variables. If you have a (stupid) macro:
(define-syntax my-list (&rest args)and a user uses it thusly:
(let ((list 12))This expands to:
(my-list 1 2 3))
(let ((list 12))Again, this causes no problem, because different colors don't interact.
(list 1 2 3))
Everytime you create a piece of code with quasiquote, the system generates a new unique color.