clojure-dev

bronsa 2023-01-03T10:12:34.666249Z

hmm, those all cause an exception to be thrown in tools.reader

bronsa 2023-01-03T10:16:29.058119Z

ah nevermind, with :features #{:clj} those read exactly like in lispreader.java

borkdude 2023-01-03T19:10:34.129139Z

Should :exclude -ing ns be supported?

user=> (ns foo (:refer-clojure :exclude [ns]))
nil
foo=> (resolve 'ns)
#'clojure.core/ns

borkdude 2023-01-03T19:16:18.442149Z

This doesn't work for me either:

bar=> (ns-unmap *ns* 'ns)
nil
bar=> (resolve 'ns)
#'clojure.core/ns

borkdude 2023-01-03T19:17:48.828699Z

I'd post an issue (+ patch) after receiving some feedback on this

borkdude 2023-01-03T19:19:19.240639Z

It seems there is a hardcoded case for this: https://github.com/clojure/clojure/blob/527b330045ef35b47a968d80ed3dc4999cfa2623/src/jvm/clojure/lang/Compiler.java#L7446

borkdude 2023-01-03T19:24:46.618339Z

I think I found a workaround using definterface

Alex Miller (Clojure team) 2023-01-03T19:46:18.895359Z

not sure what you're looking for, it's a special case

borkdude 2023-01-03T19:48:54.657299Z

I was trying to define a protocol with an ns method to get compatibility in SCI with clojure.lang.Var but this isn't possible without emitting warnings

borkdude 2023-01-03T19:49:42.921419Z

but I managed to work around it using definterface:

$ ./sci "(let [v #'inc] (.name (.ns v)))"
clojure.core

borkdude 2023-01-03T19:50:19.761969Z

You might wonder why: well, I'm trying to make a library that you wrote compatible with bb, without changing it too much ;)

Alex Miller (Clojure team) 2023-01-03T19:51:21.279329Z

I think there is a better option for that idiom now

borkdude 2023-01-03T19:52:07.640359Z

perhaps:

user=> (-> #'inc symbol namespace)
"clojure.core"

Alex Miller (Clojure team) 2023-01-03T19:52:08.569879Z

(namespace (symbol #'inc))

Alex Miller (Clojure team) 2023-01-03T19:52:15.209559Z

yeah

Alex Miller (Clojure team) 2023-01-03T19:52:31.095039Z

we made those changes to symbol in 1.9 or 1.10

Alex Miller (Clojure team) 2023-01-03T19:52:42.635319Z

sure

borkdude 2023-01-03T19:53:03.820109Z

cool, then I'll roll back my changes :)

borkdude 2023-01-03T19:53:38.109379Z

the full idiom is: (-> #'inc symbol namespace symbol) to get back a namespace symbol

borkdude 2023-01-03T19:57:53.985669Z

This was introduced in 1.10, I guess clojure spec was introduced in 1.9 right

Alex Miller (Clojure team) 2023-01-03T19:58:01.752669Z

yeah

Alex Miller (Clojure team) 2023-01-03T19:58:39.037039Z

committed in t.b - do you need a release?

borkdude 2023-01-03T19:59:17.604459Z

not necessary - thanks!

borkdude 2023-01-03T19:59:36.525269Z

I still come across this interop a lot, e.g. recently I made a PR here: https://github.com/borkdude/hyperfiddle-rcf/commit/9ce258d75a87cd8c8d9ab6b5fa01f3ca37a29782

Alex Miller (Clojure team) 2023-01-03T20:00:23.853729Z

yeah, this was a common thing, that's why we modified symbol

👍 1
Alex Miller (Clojure team) 2023-01-03T20:07:26.705269Z

I committed the switch in spec.alpha too

borkdude 2023-01-03T20:07:56.056089Z

wouldn't that make spec.alpha incompatible with 1.9?

Alex Miller (Clojure team) 2023-01-03T20:08:10.899659Z

it already depends on 1.10.3

borkdude 2023-01-03T20:08:28.173899Z

cool, then I can remove one more diff in babashka.spec.alpha!

borkdude 2023-01-03T20:43:33.323109Z

I also updated babashka spec alpha with the latest spec alpha changes (pull upstream) If you're interested, the diff is here: https://github.com/clojure/spec.alpha/compare/master...babashka:spec.alpha:babashka?w=1 The biggest difference is clojure.lang.Compiler/demunge not (yet) being available in bb, so it works around that by using clojure.main/demunge

borkdude 2023-01-03T20:45:10.432749Z

I guess:

(symbol (str (.name *ns*)) (str s))
could also use ns-name

borkdude 2023-01-03T20:45:39.394589Z

or simply str