This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-21
Channels
- # announcements (12)
- # architecture (26)
- # beginners (165)
- # biff (19)
- # calva (25)
- # circleci (2)
- # clj-kondo (25)
- # clojure (70)
- # clojure-dev (17)
- # clojure-europe (37)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-spec (10)
- # clojure-sweden (1)
- # clojure-uk (24)
- # clojurescript (10)
- # clr (9)
- # cursive (17)
- # data-science (2)
- # datahike (1)
- # deps-new (1)
- # dev-tooling (3)
- # emacs (3)
- # events (7)
- # helix (10)
- # honeysql (1)
- # hugsql (3)
- # humbleui (3)
- # hyperfiddle (30)
- # introduce-yourself (3)
- # jobs (1)
- # malli (4)
- # music (1)
- # off-topic (3)
- # pathom (3)
- # polylith (6)
- # portal (7)
- # re-frame (16)
- # reitit (3)
- # releases (3)
- # remote-jobs (1)
- # shadow-cljs (23)
- # xtdb (14)
Is there a helper that allows me to use quote and unquote without a macro and syntax quote? I'd like to use Clojure's macro syntax to build queries (e.g. a function that returns a part of a query) but I can only use unquote (`~`) with syntax quote (```) and not regular quote (`'`).
what is the problem you are having with syntax quote? is it that symbols are qualified to the ns
but you usually don’t need macros to build queries, just use the map form and thread that through regular functions
I want this:
(defn build-query-part [key-sym]
`[[data :data/key ~key-sym]])
(build-query-part 'hello)
; I get this:
[[my-ns/data :data/key hello]]
; I want this:
[[data :data/key hello]]
Because it's weird when I want to use and
and or
:
; To get this:
'(and [...])
; I need to type this:
(list 'and '[...])
So it would be nicer if I'd be able to use basic quote and unquote instead of syntax quote for and
:
'(and [a :a/attr ~hi])
^this form is illegal because unquote is not present inside '
.Then it would look like this:
`(~'and [~'a :a/attr ~my-outer-symbol])
A few people I know are using this with XTDB https://github.com/brandonbloom/backtick
I'll try what you said. I think the template
macro should be exactly what I want :thinking_face:
Nice.
(defn build-query-part [key-sym]
(backtick/template
[[data :data/key ~key-sym]]))
(build-query-part 'hi)
[[data :data/key hi]]
And the and
:
(defn build-query-part [key-sym key-sym2]
(backtick/template
[(and [data :data/key ~key-sym]
[data :data/key2 ~key-sym2])]))
(build-query-part 'hi 'there)
[(and [data :data/key hi]
[data :data/key2 there])]