I remember a while ago seeing a wiki page which had a list of the different categories of error messages, and comparisons of how they are handled in Clojure 1.10+ and in previous versions. I can’t find it now, can anyone help me out with a link?
The main design page was https://archive.clojure.org/design-wiki/display/design/Error%2BHandling.html
and this links to a redirect page that has a bunch of links to subsections of that https://clojure.atlassian.net/browse/CLJ-2373 (but it seems the nav is broken)
Actually, this was the page I was after, I found it via @seancorfield’s link: https://archive.clojure.org/design-wiki/display/design/Exception%2Bhandling%2Bupdate.html
Is it the intention that the data from Throwable->map
be readable? Currently for a spec error they’re not, because the spec itself is printed as #object[...]
.
Spec 1 or Spec 2?
Clojure 1.10.1
Spec 2 isn’t out yet, right?
Spec 2 is available -- wasn't sure whether you were testing against that.
No, I’m just trying to fix error cases for whatever people are using right now.
Gotcha.
How are you causing the Spec error? Just via a macro expansion?
Regarding the readability issue, that is a known issue, should really be the s/form
Yeah
Yes, that one is just a (let [x])
Thanks. I’ll transform the errors before I send them back, then. I guess when I receive them I’ll have to transform them back so that ex-triage works correctly?
Actually, that doesn’t seem necessary - just transforming on the sending side seems to work fine.
Can a type or record in clojure be extended to behave like a function and multimethod? This is easy w/ clojurescript but I'm stuck trying to get this to work in clojure. I'd appreciate any way to make this work since it breaks CLJC compatibility and with that the API of a library I'm planning to open source soon. CLJS example:
(defrecord MyMulti
[add-method remove-method dispatch-fn method-table]
IMultiFn
(-add-method [_ dispatch-val f]
(add-method dispatch-val f))
(-remove-method [_ dispatch-val]
(remove-method dispatch-val))
(-methods [_] @method-table))
there's no equivalent to IMultiFn
in clojure/jvm
@bronsa I'm aware. The question is can anything be done to make it work?
not using deftype
or defrecord
@bronsa to provide some more detail: I'm looking to be able to use defmethod
in cljc on my own type/record that exposes similar behavior.
I understand, it's not possible
Sorry about raising a topic again but I wonder why (get 1 1) ;;=> nil
? 🙂 found that from the very beginning https://github.com/clojure/clojure/commit/1c9de854a30e116e502c2d0bebaadce8f80219fb
this is widely known, and has been discussed to the point that it brings on a deep feeling of weariness to see it brough up again
but I suspect the discussions might be deep in the depths of the google group, searching of which is a pain, so you might want to throw it on http://ask.clojure.org to get an easier to find discussion
> searching of which is a pain @hiredman exactly, sorry for annoying raising it up again, I should have asked “where was the discussion”, this is really un-googlable unlike say https://stackoverflow.com/questions/28934385/why-does-count-nil-return-0 but anyway “spec says so” (here: “nil if key not present”) doesn’t answer why 🙂 could you share the essense idea of that google group thread?
I don't recall, and I don't think it was once, I just think it has come up a number of times, and my (entirely unfair and overly general) summary is: rich likes it that way
in some cases there’s a sort of “nice” flexibility in being able to do (get x "blah")
on anything for x
but it can also be an easy source of just bad/buggy code
I think, and I don't recall the argument being put in these terms, the rational is something like "it is nice for get to be a total function"
There is a jira to throw on non-associative args to get, which has been debated off and on
If I had to guess, I’d say Rich probably thinks it’s undefined
Is someone out there relying on this such that they would be broken if it changed? No idea
I was browsing through http://ClojureDocs.org page for get
to see if it mentioned any motivating reasons, but no. I did find this behavior that I probably actually documented, but had forgotten, which only happens for vectors, arrays, and strings, I believe (occurs because of truncating behavior of a call to intValue in the implementation):
user=> (get ["a" "b" "c"] 4294967296)
"a"
From where 4294967296
came from?
max unsigned integer + 1
(get ["a"] (* 2 (inc Integer/MAX_VALUE)))
(.intValue (* 2 (inc Integer/MAX_VALUE))) ;;=> 0
correct
didn't 1.5 used to work too? I think we fixed that at some point
clojure/lang/PersistentVector.java
Line 698
In 1.10.1 jar