问题
Why is '(1 2 3) written instead of (1 2 3) ?
> (list 1 2 3)
'(1 2 3)
回答1:
Racket's default printer prints a value as an expression that would evaluate to an equivalent value (when possible). It uses quote
(abbreviated '
) when it can; if a value contains an unquotable data structure, it uses constructor functions instead. For example:
> (list 1 2 3)
'(1 2 3)
> (list 1 2 (set 3)) ;; sets are not quotable
(list 1 2 (set 3))
Most Lisps and Schemes print values using the write
function instead. You can change Racket's printer to write
mode using the print-as-expression
parameter, like this:
> (print-as-expression #f)
> (list 1 2 3)
(1 2 3)
See the docs on the Racket printer for more information.
来源:https://stackoverflow.com/questions/36508406/why-does-the-racket-interpreter-write-lists-with-an-apostroph-before