cljs-dev

borkdude 2025-12-22T12:45:26.444799Z

@dnolen I noticed that the newest CLJS has a new public function called str_ which still uses the unoptimized array.join stuff which was optimized in str. Do we still need str_, what for?

dnolen 2025-12-22T18:24:15.847569Z

str_ is for code size

borkdude 2025-12-22T18:49:28.867429Z

I don't understand. How does str_ produce better code size?

cljs.user=> (str (fn [] (str_ 1 2)))
"function (){\nreturn [cljs.core.str_((1)),cljs.core.str_((2))].join('');\n}"
cljs.user=> (str (fn [] (str 1 2)))
"function (){\nreturn (\"\"+(1)+(2));\n}"

dnolen 2025-12-22T18:52:08.396259Z

rest arg functions normally depend on IndexedSeq this is a non-trivial thing to pull in - it creates a kind of recursive reference later w/ printing, str_ breaks it

dnolen 2025-12-22T18:53:07.966159Z

it also just makes DCE easier to reason about - w/o it, was pretty opaque

borkdude 2025-12-22T18:53:43.086669Z

We could still optimize the str_ as macro bit perhaps so the internal calls just get compiled to +?

borkdude 2025-12-22T19:02:12.785719Z

I wonder if this should be undefined? as well? https://github.com/clojure/clojurescript/blob/c4295f303100bbf5afac449242d30bca1126f1a1/src/main/cljs/cljs/core.cljs#L3113

borkdude 2025-12-22T19:02:58.271479Z

What if you call (str_ nil 1). I guess since it's only used internally it doesn't matter much since that's probably not the case right now, but can be a footgun later on perhaps

borkdude 2025-12-22T19:05:48.746559Z

Anyway, my proposal would be to avoid the array + .join like we did for str and apply the same optimization to str_ too. https://github.com/borkdude/clojurescript/commit/b0f9e0ac2e097674568a1fdd92912f6c567ecb6a

borkdude 2025-12-22T14:50:43.741259Z

@dnolen found a bug I think.

cljs.user=> (refer-global :only '[String] :rename '{String Str})
nil
cljs.user=> String
#object[String]
cljs.user=> Str
#object[String]
The name String should not be resolvable will :rename . I'll make an issue + patch if you agree.

dnolen 2025-12-22T18:24:41.933629Z

I agree, patch welcome

borkdude 2025-12-22T19:45:28.328689Z

done: https://clojure.atlassian.net/browse/CLJS-3468

Alex Miller (Clojure team) 2025-12-22T16:50:28.202399Z

https://ask.clojure.org/index.php/14847/max-x-y-used-to-return-y-now-it-returns-x

dgr 2025-12-25T18:36:53.370699Z

@borkdude, I wrote the tests for min and max. They definitely try to test some negative cases. JVM throws exceptions if not a number; CLJS and others will sometimes accept them. Currently, the test suite captures that behavior. Over time, I expect those cases to be removed.

dgr 2025-12-25T18:43:32.886489Z

And Merry Christmas. 🙂

borkdude 2025-12-22T16:53:58.507529Z

The "correct" answer to this is probably that you shouldn't rely on cljs.core/max for non-numbers

borkdude 2025-12-22T16:59:35.100599Z

The context of this question is the jank clojure test suite which (over)tests all kinds of edge cases so it doesn't seem like a real "production" grade problem.

dnolen 2025-12-22T18:26:32.621819Z

Yes max is only for numbers