Fork me on GitHub
#clojure
<
2020-11-23
>
borkdude19:11:28

What was the recommended way of getting from var to symbol prior to this commit? https://github.com/clojure/clojure/commit/d29219f78e51da66daf1c66108ebebb97c68442f

(symbol (str (-> the-var meta :ns ns-name)) (str (-> the-var meta :name)))
?

borkdude19:11:47

It would be nice if there was some interface or protocol that defines how to get from x to symbol maybe

borkdude19:11:42

is symbol an interface or protocol?

Alex Miller (Clojure team)19:11:46

it's an interface, for some generic interpretation of the word :)

borkdude19:11:31

I'm asking this because in sci (clojure interpreter) I have a custom var implementation but of course symbol doesn't work on that one.

borkdude19:11:50

if I could implement some ISymbol and symbol used that one, it would work

borkdude19:11:01

or IVar would be even more useful to me

Alex Miller (Clojure team)19:11:28

an interface method that coerced to symbol

Alex Miller (Clojure team)19:11:48

why does it need to be open vs closed

borkdude19:11:23

well, I would use it to make my custom var work well together with symbol. Right now symbol does a series of instance checks, which could then just be one ISymbol check perhaps

Alex Miller (Clojure team)19:11:37

why do you need a custom var?

Alex Miller (Clojure team)19:11:00

(I'm not trying to be combative, just trying to understand the root of the problem)

borkdude19:11:25

because there is no IVar standard that I can reference and sci (the Clojure interpreter) does not use clojure.lang.Var but stays away from that, as I consider that implementation detail

Alex Miller (Clojure team)19:11:42

also, you listed another implementor of this interface (custom var), but my question was, in what places would clojure use the interface rather than the concrete type?

borkdude19:11:05

in the symbol function

borkdude19:11:49

users of the clojure.core standard library?

borkdude19:11:55

I basically want to make this work in sci:

user=> (symbol #'inc)
clojure.core/inc
But right now I would have to patch symbol because of its closed nature and add one instance check before it defers to clojure.core/symbol.

borkdude19:11:18

$ bb -e "(type #'inc)"
sci.impl.vars.SciVar

Alex Miller (Clojure team)19:11:54

I'm asking to be convinced that this is a problem broader than your use case :)

Alex Miller (Clojure team)19:11:38

I just honestly don't know

Alex Miller (Clojure team)19:11:49

fwiw, I think you could feel quite comfortable using clojure.lang.Var

Alex Miller (Clojure team)19:11:41

there are levels of "public" / "impl" in Clojure and I'd certainly consider the clojure core type impls to be more on the public/stable end of the dial

borkdude19:11:02

well, sci works on the JVM and in CLJS (JS). The var is implemented in .cljc so there is minimal difference between the two (or at least, the difference is very easy to see and reason about). Also clojure.lang.Var references clojure.lang.Namespace and possibly another chain of things I don't want to have in my interpreter, as this can cause problems with GraalVM possibly (bloat, or otherwise)

borkdude19:11:47

Maybe I could have used it and maybe it would have worked.

borkdude20:11:01

But I don't know what Clojure is going to do with Var in the future, so it seemed like a good idea to isolate this a bit

borkdude20:11:56

Right now I recommend to use :meta to get to the name of the var, but I was wondering how people did this before symbol supported clojure.lang.Var

borkdude20:11:48

I can just map a slight variation of symbol in sci that works with sci.impl.vars.Var, no problem actually. But it just got me wondering.

arthur19:11:32

what's the proper channel to be confused on cider and nrepl problems in? I'm trying to figure out how to have two cider scratch buffers pointed to different nrepls in different projects in the same emacs

andy.fingerhut19:11:26

There is a #cider channel that sounds appropriate.