I'm used to (quote x)
evaluating to x
, (quote (x y z))
evaluating to (x y z)
, and (car (quote (x y z))
evaluating to x
. The reasoning is simple: quote is a special form that does not evaluate its argument, but simply returns it as is.
I just started using Racket, and it thinks that (quote x)
evaluates to (quote x)
, (quote (x y z))
evaluates to (quote (x y z))
, and (car (quote (x y z))
evaluates to (quote x)
.
Well, actually, it prints these as 'x
, '(x y z)
, and 'x
, respectively, but that's the same thing.
Can someone explain the reasoning here? If, for some reason, (quote (x y z))
evaluates to (quote (x y z))
, shouldn't the car of that then be quote
? Where does (quote x)
come from?
As far as I can tell, Racket, throughout the entire computation, internally behaves just as I'm used to, except that when it comes time to print the final result, it wraps it in a quote form. Is this correct in all cases? And if so, why would it want to do that?