27 ms·
This is some kind of a sad example you put here on HN... This is basically the worst part of Clojure (and only on the JVM at that): catching a Java exception.
by martinced 14y ago
This is some kind of a sad example you put here on HN...
This is basically the worst part of Clojure (and only on the JVM at that): catching a Java exception.
I know that's not your point but --and I'm a huge Clojure fan-- seeing a Java idiosynchrasy like that one makes me want to give up Clojure : (
- sirclueless 14y agoIn this case it's a Java wart, yes, but the same thing happens with other parts of the language. Another example: "Conjoining an element to a list can be done in the reverse order" (= __ (conj '(:a :b :c :d :e) 0)) Well OK, so is `conj` just `cons` with reversed argument order, or does it append to the other end of the list? My Lisp intuition tells me that the first is more likely, but the test failure doesn't show you anything, you have to use trial and error or fire up a REPL.
- cicero 14y agoThere's more to conj. It does a cons for lists, but works differently for other types of collections. You might find it helpful to lookup things in ClojureDocs. http://clojuredocs.org/clojure_core/clojure.core/conj http://clojuredocs.org/clojure_core/clojure.core/conj
- AimHere 14y agoNot really either. Conj acts on collections (which can be lists, vectors, sets or hash maps), and adds the second and subsequent arguments to the collection in a type-dependent way. For a list, your hunch is correct, in that it's a bit like a reversed-argument 'cons', except that you can have add more than one item to the list; e.g. (conj '(:a :b :c) :d :e :f) returns (:f :e :d :a :b :c)