Note that 'x
is just a reader abbreviation for (quote x)
. For that reason, when you write (TEST '("A"))
, it is exactly the same as writing (TEST (quote ("A")))
. Therefore, it matches the first pattern, where <table>
is bound to quote
and <name>
is bound to ("A")
.
This might be a little confusing, but keep in mind that macros operate entirely at compile-time. For that reason, '("A")
is never evaluated to anything before being passed to the macro, it’s just handed off directly. The syntax-rules
pattern-matching construct doesn’t care at all about the special meaning of quote
, it just matches against the syntactic structure of lists and pairs, so you get the behavior you’ve discovered.
Depending on what you are actually trying to do, there are a couple ways to get the behavior you might want. If you want pattern-matching against runtime values, use match
, not syntax-rules
. If you really want a macro, but you want to be more specific about the kinds of things that will match, you might want to use syntax-parse
instead of syntax-rules
. Without more information, though, it’s hard to give a concrete suggestion.