cljs-dev

souenzzo 2024-05-21T14:25:18.528329Z

Hello I think that this issue should be re-opened https://clojure.atlassian.net/browse/CLJS-1670 The current differences page does not include any mention to this difference/limitation https://clojurescript.org/about/differences

2024-05-21T14:37:21.557649Z

> Namespaces in ClojureScript are compiled to Google Closure namespaces which are represented as nested JavaScript objects. Importantly this means that namespaces and vars have the potential to clash - however the compiler can detect these problematic cases and will emit a warning when this occurs. First paragraph on https://clojurescript.org/about/differences#_namespaces section.

πŸ‘ 1
souenzzo 2024-05-21T14:40:20.318969Z

i was seeking for "conflict" keyword. facepalm

souenzzo 2024-05-21T14:32:10.865269Z

On this feature, the design is incomplete? A patch is welcome? https://clojure.atlassian.net/browse/CLJS-3233

dnolen 2024-05-21T17:23:00.002869Z

@souenzzo it does mostly work as far as I know as noted by @thheller - I think one design problem is that we’re pretty late in the game - someone might have a single segment namespace called global … I guess we could detect that

dnolen 2024-05-21T17:23:23.312229Z

the only thing missing from CLJS-3233 is sugar I think

dnolen 2024-05-22T13:18:51.753209Z

right sorry forgot to clarify js/ is undesirable because it would be something new for the ns form

borkdude 2024-05-21T17:28:01.258579Z

So the idea is now: global.foo :refer [bar]? I think globalThis would be less chance of clashing with anything since that is a defined constant in JS environments now

thheller 2024-05-21T17:32:59.450239Z

on thought that comes to mind is that we already have the js/ special. we could just transfer (:require [js/some.thing :as x :refer (foo)]). might break some tools and specs so probably not the best idea, but seems nice

πŸ‘ 1
borkdude 2024-05-21T17:34:17.939169Z

yeah or js$some.thing

borkdude 2024-05-21T17:35:10.213259Z

or globalThis$some.thing , both ok to me

dnolen 2024-05-21T18:05:28.289859Z

js$some.thing is very short and less likely to cause much trouble

πŸ‘ 1
souenzzo 2024-05-21T20:44:16.879149Z

(:require [js/foo.bar :as car]) is pretty awesome. Already solves my problem

borkdude 2024-05-21T21:17:45.783839Z

how do you mean "already"? it works with the currently released CLJS?

borkdude 2024-05-21T21:26:11.596489Z

as thheller notes, js/... violates the clojure.spec for the ns form currently, therefore js$ might be the way to go (and $ is already an existing convention in CLJS ns form)

thheller 2024-05-22T04:49:30.517599Z

agreed, js$ seems fine. close enough to js/ and it is very unlikely anyone has a js namespace, which we than could also ban/warn about

πŸ‘ 1