clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
borkdude 2020-11-23T19:01:28.107200Z

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)))
?

borkdude 2020-11-23T19:05:47.107700Z

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

2020-11-23T19:16:32.109300Z

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

alexmiller 2020-11-23T19:42:43.109500Z

there is: symbol

borkdude 2020-11-23T19:44:42.109700Z

is symbol an interface or protocol?

alexmiller 2020-11-23T19:45:46.110Z

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

borkdude 2020-11-23T19:45:58.110200Z

ha ha.

borkdude 2020-11-23T19:46:31.110400Z

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.

borkdude 2020-11-23T19:46:50.110600Z

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

borkdude 2020-11-23T19:47:01.110800Z

or IVar would be even more useful to me

alexmiller 2020-11-23T19:47:42.111300Z

who would use that?

borkdude 2020-11-23T19:47:55.111500Z

that = ?

alexmiller 2020-11-23T19:48:28.111700Z

an interface method that coerced to symbol

alexmiller 2020-11-23T19:48:48.111900Z

why does it need to be open vs closed

borkdude 2020-11-23T19:49:23.112100Z

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

alexmiller 2020-11-23T19:49:37.112300Z

why do you need a custom var?

alexmiller 2020-11-23T19:50:00.112500Z

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

borkdude 2020-11-23T19:50:25.112700Z

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

alexmiller 2020-11-23T19:50:42.112900Z

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?

borkdude 2020-11-23T19:51:05.113100Z

in the symbol function

alexmiller 2020-11-23T19:51:22.113300Z

but who uses that?

borkdude 2020-11-23T19:51:49.113500Z

users of the clojure.core standard library?

2020-11-23T19:52:26.113700Z

There is a #cider channel that sounds appropriate.

borkdude 2020-11-23T19:52:55.113900Z

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.

borkdude 2020-11-23T19:53:18.114100Z

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

alexmiller 2020-11-23T19:53:54.114300Z

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

borkdude 2020-11-23T19:54:15.114500Z

maybe not

alexmiller 2020-11-23T19:54:38.114700Z

I just honestly don't know

alexmiller 2020-11-23T19:54:49.114900Z

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

alexmiller 2020-11-23T19:55:41.115100Z

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

borkdude 2020-11-23T19:57:02.115300Z

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)

borkdude 2020-11-23T19:59:47.115800Z

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

borkdude 2020-11-23T20:00:01.116Z

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

borkdude 2020-11-23T20:00:56.116200Z

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

borkdude 2020-11-23T20:01:48.116500Z

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.