Extra finding around CLJS-3415: clojurescript do have https://github.com/clojure/clojurescript/blob/v1.11/src/main/cljs/cljs/core.cljs#L7045 function
But I can't find any usage of it.
Given this commit:
https://github.com/clojure/clojurescript/commit/841254a96066ea14da9a4f647b41e13a7c5e0026
I think that tools.reader has a bug https://github.com/clojure/tools.reader/blob/master/src/main/cljs/cljs/tools/reader/edn.cljs#L203 and it should use createWithCheck.
doesn't matter. it doesn't need to check again when constructing. it is already checked when reading
Those are checking different things if I understand what you’re talking about
The reader checks for identical forms, the data structure checks for identical values
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 }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
#{1 1} ;; read check
(let [a 1 b 1] #{a b}) ;; data structure checkyeah 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 ;)
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
Making something less restrictive isn’t a breaking change probably?
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
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)
That’s a good point
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)