clojure

hrtmt brng 2025-11-30T11:16:49.587749Z

Why is there no unquote for quote? Instead of this

(d/q '[:find ?e
       :in $ ?alias
       :where
       [?e :aka ?alias]]
     (d/db conn)
     name)
we could write
(d/q '[:find ?e
       :where
       [?e :aka ~name]]
     (d/db conn))
.

2025-12-01T09:34:07.289109Z

If you want a syntax quote / unquote without namespace qualifying you can take a look at https://github.com/brandonbloom/backtick

☝️ 1
Casey 2025-12-04T13:15:31.745639Z

i've used backtick many times with good success, the template macro is very useful

p-himik 2025-11-30T11:20:08.279999Z

There is. It's just that unquote (the actual special behind the ~ sugar) works only with the syntax quote. But then you have the issue where ?e is syntax-quoted, so you'd have to circumvent it with ~'?e.

🙌 1
p-himik 2025-11-30T11:20:22.229989Z

Ah, I guess that's exactly your question then. :)

p-himik 2025-11-30T11:21:22.281869Z

The regular quote quotes everything, regardless of specials. Adding an unquote to it would make it not work in any scenarios where you need to, well, quote clojure.core/unquote. There would be some scenarios that are impossible to implement.

seancorfield 2025-11-30T16:05:03.155689Z

You could just quote the symbol ?e in that:

(d/q [:find '?e
      :where
      ['?e :aka name]]
     (d/db conn))

1
seancorfield 2025-11-30T16:06:00.373269Z

Or even:

(let [?e '?e]
  (d/q [:find ?e :where [?e :aka name]] (d/db conn))

p-himik 2025-11-30T16:07:44.945639Z

Heh, neat. Now it's just a matter of somebody coming over and making letq that lets you (letq [?a ?b ?c] (d/q ...)). :D

3
pushpankar kumar 2025-12-01T04:27:37.172359Z

(defmacro letsym [syms & body]
  (let [bindings (mapcat (fn [sym]
                           [sym `'~sym]) syms)]
    `(let [~@bindings]
       ~@body)))

(macroexpand-1 '(letsym [?a ?b ?c]
                  (do-something)))

(let [v 1]
  (letsym [?a ?b ?c]
    [:find ?a
     :where [?a :data/value ?b]
     [?b :data/next-val v]]))
😄

hrtmt brng 2025-12-01T05:06:21.610299Z

Before you try to implement such a macro. I have this already: https://clojureverse.org/t/create-code-like-data-structures-dynamically/10903/10?u=habruening But the question is, why does Clojure not have something like this already? And why doesn't Datomic bring data into the query in this way?