4 ms·
Or in Clojure: { "posts" { "id" "1", "title" "Rails is Omakase", "rels" { "author" 9, "comments" [ 5, 12, 17, 20 ] } } } Commas are unnecessary, I kept them
by notimetorelax 13y ago
Or in Clojure:
{ "posts" { "id" "1", "title" "Rails is Omakase", "rels" { "author" 9, "comments" [ 5, 12, 17, 20 ] } } }
Commas are unnecessary, I kept them for clarity.
- klibertp 13y agoI'm not sure I like this syntax. It's unfamiliar both to lispers and "mainstreamers". The former will be irritated with { and commas, the latter will try to insert : everywhere. I read an interview with Rich Hickey where he said that adding these three syntax constructs reduced cognitive burden on programmers. He meant () for lists, [] for vectors and {} for hashes. I should implement it in Racket and just see how it feels.
- notimetorelax 13y agoThere was a discussion on the mailing list concerning colon in maps, here's the JIRA issue [1]. IIRC it was kind of decided to let it die, but maybe someone will implement it. Personally I think that differentiating between lists and maps is important and the way Clojure does it (as well as JSON) is quite easy to write and read. FWIW example given by bitcracker is broken because there's no way to understand what does the following mean: (rels (author 9) (comments (5 12 17 20))) The outermost element is it a list or a map? [1] http://dev.clojure.org/jira/browse/CLJ-899 http://dev.clojure.org/jira/browse/CLJ-899
- draegtun 13y agoWouldn't it be better to use keywords here?: { :posts { :id 1 :title "Rails is Omakase" :rels { :author 9 :comments [5 12 17 20] }}}
- bitcracker 13y agoYes, this is the usual way in Common Lisp.