@todo has joined the channel
I’m trying to understand how quote, unquote, quasiquote interact with each other. Part of the problem I run into is that if I type in:
(quote x)
in the repl, it returns
'x
which is correct, but not as useful when I try to work through things step by step.
Is there a way to disable `’ in the Racket output, so it writes it out long form (i.e. using quote/quasiquote) ?
My only ideas would be to use either (print-reader-abbreviations #f) or (pretty-print-abbreviate-read-macros #f), but those don’t seem to apply for the ' tick in 'x, so I don’t know what else to do
@todo I was curious so I fiddled around with making a printer based on mzlib/pconvert, and got a printer that does this: > 'x
(quote x)
> '(a b 'c `d ,e ,@f #'g #`h #,i #,@j)
(list
(quote a)
(quote b)
(list (quote quote) (quote c))
(list (quote quasiquote) (quote d))
(list (quote unquote) (quote e))
(list (quote unquote-splicing) (quote f))
(list (quote syntax) (quote g))
(list (quote quasisyntax) (quote h))
(list (quote unsyntax) (quote i))
(list (quote unsyntax-splicing) (quote j))) I’m not sure whether that’s what you’re looking for, or whether you want something else
Basically if you do (pretty-write (print-convert ...some-value...) out) while constructor-style-printing is true and pretty-print-abbreviate-read-macros is false, then it will print a symbol like 'x as (quote x). However, it will also print lists with list instead of quote, which might be a good thing or a bad thing depending on how you feel about quote
@alexknauth: Thanks! This looks great. Given the request to show quote/quasiquote literrally, I think the literal list is unavoidable.
This is a bit of an x-y problem. Scheme is famous for it’s 1–2 page interpreters. Is there a 1–2 page CODE implementing quote/quasiquote/unquote somewhere? In the first 2–3 pages of Google I’ve looked through, I keep on getting simple examples of how quote/quasiquote/unquote work … but I am trying to implement quote/quasiquote/unquote myself for a toy language, and would really like to see actual impl.