aaalex88
aaalex88

Reputation: 649

how quasiquotes are represented in syntax tree (CL)

I understand how quotes are represented in language:

(equal ''(1 2) (list 'quote (list 1 2))) ;; => T

but what about quasi-quotes? is it something like:

(equal ``(1 2) (list '<???> (list 1 2)))

Both quasiquote and backquote instead of <???> don't work.

Upvotes: 1

Views: 188

Answers (2)

Rainer Joswig
Rainer Joswig

Reputation: 139241

Generally there is no representation required:

 '`(1 2) -> '(1 2)

 '`(,1 2) -> '(1 2)

 '`(,a 2) -> (list* a '(2))

Implementations may expand into special constructs, so that backquote expressions can also be printed as backquote expressions.

Upvotes: 2

user5920214
user5920214

Reputation:

There is no standard representation in Common Lisp. What backquote should do is specified, but there is no equivalent to quote. In particular the spec says in 2.4.6, after giving the specification of how backquote should behave:

An implementation is free to interpret a backquoted form F1 as any form F2 that, when evaluated, will produce a result that is the same under equal as the result implied by the above definition, provided that the side-effect behavior of the substitute form F2 is also consistent with the description given above.

Note that this is not in fact a problem since backquote is a thing you can implement yourself, while quote needs to be in the guts of the language.

Upvotes: 3

Related Questions