todo
2019-5-23 01:31:18

@todo has joined the channel


todo
2019-5-23 01:32:55

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) ?


alexknauth
2019-5-23 02:32:43

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


alexknauth
2019-5-23 02:57:14

@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


alexknauth
2019-5-23 03:01:57

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


todo
2019-5-23 04:44:47

@alexknauth: Thanks! This looks great. Given the request to show quote/quasiquote literrally, I think the literal list is unavoidable.


todo
2019-5-23 04:46:07

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.