cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
kommen 2021-01-14T09:15:29.001300Z

we’re running into an edge case regarding how the cljs compiler indexes node modules: https://clojure.atlassian.net/browse/CLJS-3293

kommen 2021-01-14T09:17:00.002100Z

would a patch which adds support for .cjs as main files in package.json like this be acceptable? https://github.com/nextjournal/clojurescript/commit/f48609b862062caae6d19d5d281c4f7b53a39c25

dnolen 2021-01-14T17:06:41.002300Z

sure thing

dnolen 2021-01-14T17:07:42.002600Z

@borkdude there are performance implications for that

dnolen 2021-01-14T17:08:25.003200Z

Clojure has class but that doesn't make sense for JavaScript

dnolen 2021-01-14T17:08:32.003600Z

so I just used type

dnolen 2021-01-14T17:08:45.004Z

originally this wasn't done for anything related to Clojure reallly

dnolen 2021-01-14T17:09:01.004800Z

type was missing and needed for fast membership testing

dnolen 2021-01-14T17:09:51.005900Z

you can't really just invoke -meta on anything, you will fall into a slow path

dnolen 2021-01-14T17:10:02.006200Z

at least when I looked ago not very optimizable

dnolen 2021-01-14T17:10:16.006600Z

so code that would be fast will be punished for things that don't match

dnolen 2021-01-14T17:10:44.007100Z

all that said, the issues could be separated

borkdude 2021-01-14T17:10:58.007700Z

@dnolen true, checking :meta is an extra step - is type a thing that is used in hot-loops though? Could be. Does CLJS use type internally for protocols/multimethods? It's not a big problem for me. I hit this issue in sci (Clojure interpreter) because I am using :type on its implementation of records (which are just there for compatibility).

dnolen 2021-01-14T17:11:04.007900Z

there could be a new thing that does what type used to do, and type could do Clojure behavior

dnolen 2021-01-14T17:11:26.008500Z

would need a lot of lead time on this because it would be seriously breaking behavior now

dnolen 2021-01-14T17:11:36.008900Z

so ten years of not following Clojure here might be too much water under the bridge

borkdude 2021-01-14T17:12:29.009400Z

I suspect many people aren't even aware of type + :type metadata on the JVM

dnolen 2021-01-14T17:12:34.009600Z

yes

dnolen 2021-01-14T17:12:40.009800Z

and it's not often requested

borkdude 2021-01-14T17:14:16.011200Z

So the way it works in sci now is that (= (type x) (type y)) returns true if two things are of the same record type, which I think is better than relying on the concrete return value of type. Although it was also requested to get back the namespace and name of the record type. I wonder if that is possible in CLJS at all.

dnolen 2021-01-14T17:17:14.011800Z

name is already there

dnolen 2021-01-14T17:17:19.012200Z

needed for printing

dnolen 2021-01-14T17:17:30.012500Z

and it's fully qualified

dnolen 2021-01-14T17:17:45.012800Z

it's a manually mangled property but we're not going to change it