5 ms·
'(1 2 3) '(1 2) '(1) () ; wart
by JasonFruit 5y ago
'(1 2 3)
'(1 2)
'(1)
() ; wart
- moonchild 5y agoThat's syntax sugar and it's lying to you for convenience's sake. (+ . (1 . (2 . (3 . ())))) #| --> 6 |# (quote . (1 . (2 . (3 . ())))) #| --> (1 2 3) |# (1 2 3) is a pair and we have a rule for evaluating pairs: unless the car is a symbol denoting a special form (1 is not one such), apply the car to the cdr. So we need to quote it if we want to get it as a literal. () is a special list terminator object; it is not a pair—as this dotted list syntax shows—and it has neither car nor cdr, so our previous rule for evaluation does not apply. However we have another conventional rule: objects which are not pairs and are not symbols should evaluate to themselves. This applies to strings, characters, numbers, vectors... Why not to the list terminator?
- JasonFruit 5y agoNever really thought that through. Thank you.
- moonchild 5y agoPerhaps this makes it clearer: '(1 . (2 . (3 . ()))) '(1 . (2 . ())) '(1 . ()) () The ' applies to the ., not to the ().