cljs-dev

souenzzo 2024-07-24T13:24:20.798619Z

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.

thheller 2024-07-24T13:26:55.722569Z

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

borkdude 2024-07-24T13:59:52.388919Z

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.

borkdude 2024-07-24T14:02:57.424169Z

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

borkdude 2024-07-24T14:10:28.222399Z

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

borkdude 2024-07-24T14:10:35.056079Z

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
borkdude 2024-07-24T14:14:59.387549Z

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

borkdude 2024-07-24T14:17:00.590149Z

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
borkdude 2024-07-24T14:18:48.602939Z

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)