4 ms·
I've been writing a bunch of Common Lisp recently, where I usually have been more interested in Schemes. I'm less bothered by its little inconsistencies, like
by JasonFruit 5y ago
I've been writing a bunch of Common Lisp recently, where I usually have been more interested in Schemes. I'm less bothered by its little inconsistencies, like the empty list not needing to be quoted, than I used to be. Maybe because I'm getting older, and people develop cruft just like programming languages. I'm not really small and elegant anymore, so why should my Lisp be?
- moonchild 5y ago> I'm less bothered by its little inconsistencies, like the empty list not needing to be quoted, than I used to be CL certainly has its warts, but that is not one of them. Most data types other than pairs and symbols are self-evaluating. You don't quote number literals, for instance! That the list terminator is not self-evaluating is definitely a scheme wart. (Sadly, I'm told that motions to change this behaviour in r7rs-large were rejected.)
- 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 ().