'nil 'false 'true - symbols or Clojure keywords?
Usual symbol: 'abc => abc (symbol? 'abc) => true (symbol "abc") => abc (symbol? (symbol "abc")) => true Special "symbol": 'nil => nil (symbol? 'nil) => false (symbol "nil") => nil (symbol? (symbol "nil")) => true (= 'nil (symbol "nil")) => false (= 'nil nil) => true We can see that (symbol "nil") truly evaluates to symbol nil. On the other side, reader evalutes 'nil to nil (nothing). (The same holds true for 'false and 'true.) Is this consistent and correct behavior? If it is correct, page http://clojure.org/Reader could tell more about 'nil, 'false and 'true. Thank you, Frantisek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: 'nil 'false 'true - symbols or Clojure keywords?
On Feb 17, 2009, at 5:48 PM, Frantisek Sodomka wrote: Is this consistent and correct behavior? If it is correct, page http://clojure.org/Reader could tell more about 'nil, 'false and 'true. It is correct. nil, true, and false are literals--they evaluate to themselves. They are a bit special in that if they were not literals, they would be symbols. All other literals are adorned somehow which makes it easy to see what they are: * Strings - Enclosed in "double quotes". * Numbers - Always begin with a character in: + - 0 1 2 3 4 5 6 7 8 9 (and follow some rules after that) * Characters - preceded by a backslash * Keywords - preceded by a colon The remaining literals: * nil, true, and false These are already listed in the literals section at clojure.org/ Reader. I agree that a note emphasizing that these 3 literals are unusual because they're unadorned may be helpful. --Steve smime.p7s Description: S/MIME cryptographic signature