Some “fun” news on https://github.com/jcburley/joker`gostd`https://github.com/jcburley/joker: • I pushed some significant changes a week or so ago -- but there’s much to be done, and I’m rethinking how to do that to make (at least portions of) it more palatable for eventual incorporation into official Joker • Last night, I used it to send my first email (via SMTP) -- an entirely empty one, though -- via Joker, as described in https://github.com/jcburley/joker/blob/gostd/GOSTD.md`GOSTD.md`https://github.com/jcburley/joker/blob/gostd/GOSTD.md • It’s looking more and more like this fork has exposed https://stackoverflow.com/questions/61342000/why-might-exec-command-start-hang-on-darwin: some kind of race condition, perhaps? So, while it’s hardly ready for “prime time” and is likely to undergo some substantial changes to its public-facing functionality, it’s still kinda percolating along, and bearing at least a little fruit.
is there anything like clojure.main/demunge
in joker?
what I want is to have a function (not a macro!) that receive a function object and possibly return that object's symbol. Eg (find-the-sym +)
=> joker.core/+
(Okay, it’s pretty freaky watching someone else’s comments get added and deleted LIVE while looking at my Slack window!! I know Slack supports deletion, just hadn’t seen it happen like that before. 😲)
I typed this:
(defn resolved-name [sym]
(when-let [res (resolve sym)]
(let [m (meta res)]
(symbol (str (ns-name (:ns m))) (str (:name m))))))
user=> (resolved-name '+)
joker.core/+
but then removed it as I realized this is not the same as passing the function object.and btw, I realize this is much easier:
user=> `+
joker.core/+
Yeah, I saw it and it was a good attempt, and I understood why you removed it. It was a new experience to me (in a chat channel, versus a shared doc being edited) watching it un-render itself.
Anyway, Fn
in Joker has a MetaHolder
field, but it’s typically nil
. One must have the (var …)
for it to get at the actual metadata. I don’t know offhand whether it’s feasible for Joker to put something helpful in the Fn.MetaHolder
field, nor what exactly Clojure is doing here.
One of the changes I made, to support faster initialization, was to “decorate” built-in (`Proc`) functions so they show their own names. E.g.:
user=> cons
#object[Proc:procCons]
(It used to return just #object[Proc]
.)
Possibly Joker could, a la Clojure, return more info than just #object[Fn]
when stringizing a function. From there, a joker.repl/demunge
function might be worth creating? Not sure offhand re the use cases for any of this though…maybe someone could Issue this and explain?
I know one use case in clojure spec where they try to reverse engineer a printed spec message from a function name. Let me look it up.
but I would say that is not a public Clojure API
Not in and of itself, and Joker doesn’t (yet) support Spec, but isn’t Specize
’s Object
(which calls fn-sym
) public?
yes, but their implementation is probably relying on something that the community should not use - maybe. worth asking in #clojure
btw, I have a version of spec that runs with babashka. https://github.com/borkdude/spartan.spec
it is .cljc. I'm open to receiving PRs to make it compatible with joker via a :joker
conditional.