Created
November 22, 2013 04:09
-
-
Save cjfrisz/7594736 to your computer and use it in GitHub Desktop.
The symbol 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (symbol "1") | |
1 | |
user=> (number? (symbol "1")) | |
false | |
user=> (symbol? (symbol "1")) | |
true | |
user=> (= (symbol "1") 1) | |
false | |
user=> (= (symbol "1") '1) | |
false |
(Cemerick, that wasn't meant as a slight against you, because I've seen a lot of users who need the exact explanation you just gave. I found the situation genuinely amusing, not offensive.)
I agree with @cjfrisz that, given Clojure considers itself a Lisp, it seems unexpected that symbols act so differently than in most other modern Lisps (from clisp to racket), and I think this is a pairing of printer ambiguity (which may be hectic to fix) and unexpected symbol behavior.
Is this a bug or feature?
FWIW, symbols are interned in most Lisp dialects I've used.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you have it just right, @cjfrisz. The only quibble I'd have is that if "heavyweight" was meant to refer to the relative size of each keyword / symbol, then keywords are actually the weightier of the two; each
clojure.lang.Keyword
instance contains a corresponding symbol, plus some hash stuffs. Of course, the interning of keywords you mention means that they might be faster to obtain if they're already in the pool.