Fork me on GitHub
#clojure-dev
<
2020-01-16
>
cfleming01:01:16

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?

seancorfield02:01:05

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)

cfleming02:01:51

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

seancorfield02:01:40

Spec 1 or Spec 2?

cfleming02:01:51

Clojure 1.10.1

cfleming02:01:05

Spec 2 isn’t out yet, right?

seancorfield02:01:22

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

cfleming02:01:54

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

seancorfield02:01:15

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

cfleming03:01:56

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

alexmiller02:01:35

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

cfleming03:01:16

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?

cfleming03:01:19

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

denik17:01:13

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

bronsa17:01:48

there's no equivalent to IMultiFn in clojure/jvm

denik17:01:39

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

bronsa17:01:29

not using deftype or defrecord

denik17:01:10

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

bronsa17:01:20

I understand, it's not possible

razum2um23:01:45

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

hiredman23:01:36

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

hiredman23:01:41

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

razum2um23:01:03

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

hiredman23:01:23

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

rich 8
mikerod23:01:39

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

mikerod23:01:47

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

4
hiredman23:01:55

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"

👍 4
alexmiller23:01:01

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

alexmiller23:01:23

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

alexmiller23:01:20

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

🔥 4
andy.fingerhut00:01:44

Given how prevalent get probably is in Clojure code, it seems fairly likely someone is relying upon it. There has been 12 years and tens of thousands of developers for Hyrum's law to be enacted there.

jaihindhreddy06:01:20

Hyrum's law always gets you 😄

andy.fingerhut23:01:30

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"

🤯 32
souenzzo12:01:01

From where 4294967296 came from?

favila14:01:05

max unsigned integer + 1

souenzzo15:01:11

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

alexmiller16:01:42

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

souenzzo18:01:52

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