Fork me on GitHub
#clojure
<
2021-08-01
>
vemv08:08:29

is there a function/trick that will fully-qualify a form's symbols according to (ns-aliases *ns*) ? and (ns-interns *ns*) e.g. (f '(println)) ;; => '(clojure.core/println)

vemv08:08:12

I think syntax-quote wouldn't work... I need it available at runtime

vemv08:08:11

probably doesn't exist OOTB because for an arbitrary form the answer could be broken (in form of let shadowing)... it doesn't matter for my use case ns-resolve seems handy here

thegeez11:08:49

user=> (ns a.b (:require [clojure.string :as str])) nil a.b=> (macroexpand-1 (str/lower-case "ABC"))` (clojure.string/lower-case "ABC")

p-himik12:08:12

No need for macroexpand there - the quoting is processed by the reader. @U45T93RA6 And I'm not sure you mean by "available at runtime". What's the problem that needs solving?

vemv15:08:09

syntax-quote (as in the snippet above) is a compile-time affordance. I was seeking something I can invoke against unknown inputs

vemv15:08:39

> What's the problem that needs solving? appreciate the intent however in this case I explained quite precisely the problem at hand :)

p-himik15:08:06

So instead of println you actually have something like (def my-symbol 'println)? Or perhaps that whole quoted form is just a list that's available only in run time.

vemv15:08:51

> Or perhaps that whole quoted form is just a list that's available only in run time. (edited) exactly

p-himik15:08:43

Right, seems like you have indeed found your answer then. And if you do end up needing access to let bindings, I think you can write a macro that utilizes &env.

👍 2
👀 2
Niclas20:08:59

Is there an established naming convention for vars declared with volatile!, similar to ex. how *a-var* is common for dynamic vars?

dpsutton20:08:00

Probably shouldn’t need a convention? The lexical scope of a volatile use should be pretty small and easily seen where it is created and then where it is persisted

👍 2
dpsutton21:08:14

But I’m sure you’re future self and teammates wouldn’t hate if you threw a v on the end of the symbol

Niclas21:08:21

True, and my present self tends to forget to properly deref even in small scopes 😄

dpsutton21:08:15

We’ll that should blow up quite quickly for you

dpsutton21:08:55

Oh I’m thinking of transients. That was my confusion :)

hiredman21:08:33

volatile! is a recipe for race conditions of you aren't careful, consider using an atom

2