#clojure log - Jan 29 2016

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

21:57 kenrestivo: well there is the bureaucracy of setting up a lein project, bringing in dependencies, and organizing namspaces...

21:57 which compared to, say, firing up ipython, is maybe a bit more heavyweight for small scripting-type tasks.

21:58 but yeah, once you go clojure you might never want to go back :)

23:23 macrolicious: why does #{1 2 1} produce a duplicate key error but (hash-set 1 2 1) does not?

23:24 justin_smith: macrolicious: one is a reader macro for a literal, the other is a function call

23:24 macrolicious: ok, thx

23:25 justin_smith: macrolicious: for example you might want to call (apply hash-set som-coll) and you don't want an error at runtime if there is a dup

23:25 but for #{} it's always a compile time literal you can fix

23:27 macrolicious: ah ok

23:38 Malnormalulo: strictly speaking I don't think #{} is a reader macro

23:38 it's just a literal

23:45 justin_smith: Malnormalulo: anything starting with # is a reader macro

23:46 Malnormalulo: as documented under "Macro characters" here http://clojure.org/reference/reader

23:53 Malnormalulo: weird that the read-string function doesn't parse it into something else, then

23:54 justin_smith: Malnormalulo: like most # dispatched reader macros, its printed form is the same as the dispatched form

23:54 but all those things starting with # are reader macros, in fact clojure doesn't let you make new reader macros that don't start with #

23:55 Malnormalulo: huh

23:55 justin_smith: clojure reader dispatch is not like common lisp reader macros, it's much more limited

23:55 there's a good argument for maybe not using the term, but that's already too late, clojure.core already adopted the term

23:56 Malnormalulo: I'm not familiar with common lisp. I just am surprised to see something termed a macro that doesn't preprocess into other code.

23:56 justin_smith: it's custom reader code, which runs before anything else, including regular macros

23:57 usually used for creating data literals

23:57 eg. when you create a record, clojure creates a reader for that record automatically

23:57 some of them don't round trip - eg. #()

23:58 ,'#(+ % %)

23:58 clojurebot: (fn* [p1__25#] (+ p1__25# p1__25#))

23:58 justin_smith: that one is much more obviously a macro - the printed form is very different from the input form

23:58 Malnormalulo: that's the sort of behavior I'd expect from a macro

23:58 justin_smith: right -the difference with the data literals, is they were defined to print their own macro

23:58 it's clever and very convenient :)

Logging service provided by n01se.net