While writing a function in Racket I accidently put two single quotes in front of a symbol instead of one. i.e. I accidently wrote ''a and discovered some behaviour of nested quotes that seems strange. I'm using DrRacket and tested this with both the Racket lang and the R5RS lang.
(write (pair? (quote (quote a))))
prints: #t .
(write (car (quote (quote a))))
prints: quote
But
(write (quote (quote a)))
and
(write '(quote a)))
Both print: 'a
Can someone tell me why in Scheme (and Racket) the function pair? interprets (quote (quote a))) as a pair of two elements quote and a , but the function write prints out 'a instead of (quote a) .