I am writing a scheme interpreter in scheme (well, Racket). In my parse/eval function, I have the following rule:
(quotation [(Q datum) (string->symbol $2)])
string->symbol
is apparently an incorrect definition of quote
in such an interpreter.
I have tried many other ways, but none of them worked. Of course, if I try using the Racket quote
function it doesn't work, since the $2
is interpreted literally, so everything evaluates to $2
.
Now, if I evaluate some examples at the REPL:
$> (eval '1)
$> 1
$> (eval '#f)
$> #f
$> (eval 's)
$> s
VS. the Racket REPL:
$> (eval '1)
$> 1
$> (eval '#f)
$> #f
$> (eval 's)
$> 's
Note the difference: (eval 's) -> s in mine, -> 's in Racket. Furthermore, doing (symbol? (eval x))
also behaves differently.
How I am supposed to implement quote
in such a case?