cljs-dev 2024-07-24

doesn't matter. it doesn't need to check again when constructing. it is already checked when reading

Alex Miller (Clojure team) 2024-07-24T13:57:49.549959Z

Those are checking different things if I understand what you’re talking about

Alex Miller (Clojure team) 2024-07-24T13:58:20.585299Z

The reader checks for identical forms, the data structure checks for identical values

Alex Miller (Clojure team) 2024-07-24T13:59:23.311289Z

Latter is after evaluation

What's the reason for this compile time + runtime checking anyway? I for one never had a case where it was a huge problem that it behaved the way hash-map did, but I could be missing something of course.

Not the most loved language, but JS doesn't make a fuzz about it:

> {a: 1, a: 2}
{ a: 2 }

Alex Miller (Clojure team) 2024-07-24T14:05:09.437749Z

the read check disallows b/c it is not valid to say a literal set with the same two elements. the data structure may be created via some other means (not reading) so also needs to check

Alex Miller (Clojure team) 2024-07-24T14:07:54.063219Z

#{1 1} ;; read check
(let [a 1 b 1] #{a b}) ;; data structure check

yeah I got that, but there's more stuff in clojure that could do with some checking, it seems a bit arbitrary to me that this is locked down (while other languages like JS do not do this) and many other things are not

it is what it is ;)

Alex Miller (Clojure team) 2024-07-24T14:12:48.928989Z

the other other case is (conj #{1} 1) which dedupes and I think it would be reasonable for (let [a 1 b 1] #{a b}) to dedupe instead, but I don't think we can change that now

👍 1

Making something less restrictive isn’t a breaking change probably?

Alex Miller (Clojure team) 2024-07-24T14:15:51.145709Z

unless people are relying on the error, which is hard to say

error -> valid isn't a breaking change imo. also changing error messages or the type of exception or stacktrace might be considered a breaking change, but I don't think I've seen this treated as such in the history of clojure

Alex Miller (Clojure team) 2024-07-24T14:17:44.699849Z

one place where this really matters is in bulk loading of data structures where you might know (due to external knowledge) that no checks are necessary and want to avoid them for performance, and that is something we have on the list to look at (think json -> clojure)

👍 1

That’s a good point

Alex Miller (Clojure team) 2024-07-24T14:05:50.892019Z

there are some weird ramifications from the read check like

Clojure 1.11.3
user=> #{(rand) (rand)}
Syntax error reading source at (REPL:1:17).
Duplicate key: (rand)