clojure-dev 2023-01-03

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

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

Should :exclude -ing ns be supported?

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

This doesn't work for me either:

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

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

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

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

but I managed to work around it using definterface:

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

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

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

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

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

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?

not necessary - thanks!

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

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

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

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

I guess:

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

or simply str