In fact they are symbols, but print as keywords:
user=> (symbol ":a")
:a
user=> (symbol? (symbol (str :a)))
true
2017-10-09 16:26 GMT+08:00 Peter Hull :
> Slightly off-topic, but why doesn't using the 'incorrect' alphabet-macro
> give an error? If I try and define a
Slightly off-topic, but why doesn't using the 'incorrect' alphabet-macro
give an error? If I try and define a Record with keyword keys it tells me
very clearly not to:
user=> (defrecord Wrong [:a])
CompilerException java.lang.AssertionError: defrecord and deftype fields
must be symbols,
Ooh, thanks for your tips.
On Sun, Oct 8, 2017 at 7:19 PM, dennis zhuang wrote:
> First, the alphabet-macro is wrong, it should use name instead of str in
> comp:
>
> user=> (macroexpand-1 '(alphabet-macro))
> (do (clojure.core/defrecord Alphabet [:a :b :c :d :e :f :g :h
First, the alphabet-macro is wrong, it should use name instead of str in
comp:
user=> (macroexpand-1 '(alphabet-macro))
(do (clojure.core/defrecord Alphabet [:a :b :c :d :e :f :g :h :i :j :k :l
:m :n :o :p :q :r :s :t :u :w :v :x :y :z]) (def dummy-record (Alphabet. 0
1 2 3 4 5 6 7 8 9 10 11 12
As I read JoyOfClojure, it says one of reasons that prefer record over
plain map is speed, out of curiosity I test this using
https://github.com/hugoduncan/criterium, but the result is just contrary
to my expectation. record is slower than map. Is there any optimizations
made to clojure 1.8.0