Hacker News new | past | comments | ask | show | jobs | submit login

That'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?




Never really thought that through. Thank you.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: