clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
cfleming 2020-01-16T01:34:16.055500Z

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?

dpsutton 2020-01-16T02:28:19.055700Z

https://insideclojure.org/2018/12/17/errors/

seancorfield 2020-01-16T02:29:08.056100Z

The main design page was https://archive.clojure.org/design-wiki/display/design/Error%2BHandling.html

seancorfield 2020-01-16T02:34:05.057200Z

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)

cfleming 2020-01-16T02:34:05.057300Z

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

cfleming 2020-01-16T02:36:51.058700Z

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[...].

seancorfield 2020-01-16T02:37:40.058900Z

Spec 1 or Spec 2?

cfleming 2020-01-16T02:37:51.059100Z

Clojure 1.10.1

cfleming 2020-01-16T02:38:05.059400Z

Spec 2 isn’t out yet, right?

seancorfield 2020-01-16T02:39:22.059800Z

Spec 2 is available -- wasn't sure whether you were testing against that.

cfleming 2020-01-16T02:39:54.060200Z

No, I’m just trying to fix error cases for whatever people are using right now.

seancorfield 2020-01-16T02:42:48.060400Z

Gotcha.

seancorfield 2020-01-16T02:47:15.061300Z

How are you causing the Spec error? Just via a macro expansion?

alexmiller 2020-01-16T02:51:35.062Z

Regarding the readability issue, that is a known issue, should really be the s/form

alexmiller 2020-01-16T21:06:40.070200Z

Yeah

cfleming 2020-01-16T03:00:56.063200Z

Yes, that one is just a (let [x])

cfleming 2020-01-16T03:06:16.063400Z

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?

cfleming 2020-01-16T03:59:19.063600Z

Actually, that doesn’t seem necessary - just transforming on the sending side seems to work fine.

denik 2020-01-16T17:29:13.066800Z

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))

bronsa 2020-01-16T17:31:48.067100Z

there's no equivalent to IMultiFn in clojure/jvm

denik 2020-01-16T17:35:39.068300Z

@bronsa I'm aware. The question is can anything be done to make it work?

bronsa 2020-01-16T17:36:29.068600Z

not using deftype or defrecord

denik 2020-01-16T17:38:10.069800Z

@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.

bronsa 2020-01-16T17:38:20.070Z

I understand, it's not possible

razum2um 2020-01-16T23:05:45.071400Z

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

2020-01-16T23:15:36.072500Z

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

2020-01-16T23:16:41.073800Z

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

razum2um 2020-01-16T23:26:03.077200Z

> 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?

2020-01-16T23:27:23.078500Z

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

2
2020-01-16T23:28:39.079600Z

in some cases there’s a sort of “nice” flexibility in being able to do (get x "blah") on anything for x

2020-01-16T23:28:47.080Z

but it can also be an easy source of just bad/buggy code

➕ 1
2020-01-16T23:28:55.080400Z

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"

👍 1
alexmiller 2020-01-16T23:47:01.082300Z

There is a jira to throw on non-associative args to get, which has been debated off and on

alexmiller 2020-01-16T23:48:23.083500Z

If I had to guess, I’d say Rich probably thinks it’s undefined

alexmiller 2020-01-16T23:49:20.084200Z

Is someone out there relying on this such that they would be broken if it changed? No idea

🔥 1
2020-01-16T23:50:30.084800Z

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"

🤯 8
souenzzo 2020-01-17T12:10:01.001200Z

From where 4294967296 came from?

favila 2020-01-17T14:59:05.001400Z

max unsigned integer + 1

souenzzo 2020-01-17T15:52:11.001600Z

(get ["a"] (* 2 (inc Integer/MAX_VALUE)))
(.intValue  (* 2 (inc Integer/MAX_VALUE))) ;;=> 0

favila 2020-01-17T15:58:36.002Z

correct

alexmiller 2020-01-17T16:11:42.002200Z

didn't 1.5 used to work too? I think we fixed that at some point

souenzzo 2020-01-17T18:20:52.002600Z

clojure/lang/PersistentVector.java Line 698 In 1.10.1 jar