This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-11
Channels
- # announcements (6)
- # babashka (61)
- # beginners (85)
- # calva (21)
- # cider (6)
- # clara (9)
- # clj-http (1)
- # clj-kondo (35)
- # cljfx (6)
- # clojure (91)
- # clojure-australia (11)
- # clojure-europe (23)
- # clojure-italy (7)
- # clojure-losangeles (2)
- # clojure-nl (27)
- # clojure-uk (107)
- # clojurescript (4)
- # community-development (1)
- # cursive (69)
- # emacs (12)
- # fulcro (29)
- # graalvm (25)
- # honeysql (10)
- # hugsql (3)
- # integrant (13)
- # jobs (4)
- # kaocha (3)
- # keechma (1)
- # lambdaisland (3)
- # leiningen (2)
- # meander (17)
- # mount (3)
- # observability (1)
- # off-topic (86)
- # pathom (3)
- # polylith (2)
- # practicalli (14)
- # reitit (14)
- # shadow-cljs (61)
- # startup-in-a-month (1)
- # tools-deps (9)
- # vim (54)
- # xtdb (16)
I am running into a slight issue with my own hook to parse one of the om.tools/defcomponentk
macros. The macro usage looks like this:
(defcomponentk wow-component [[:data a b c d] [:state wow mate]]
(display-name [_]
"Lol")
(component-did-mount [_])
(render [_]
(+ a b c d wow mate)))
I need all those vars a b c d wow mate
be resolved, so I wrote one transformer and right before it returns it does a (prn (api/sexpr new-node))
and shows me this:
(defn wow-component [a b c d wow mate] (letfn [(_ [_] "Lol") (_ [_]) (_ [_] (+ a b c d wow mate))]))
basically I am turning the defcomponent
into one defn
and then wrapping the whole body in one letfn
since that was the closest similar structure I could find
here's the code for the hook: https://gist.github.com/verma/58a6c170189b5cf3dc9bf4103ce2e475
So the node is returned? What if you return just a token node, just for debugging? Then it should not report those locals
I tried returning (api/token-node '_)
and it said: test.clj::: error: Unresolved symbol: _
which seems right. when I comment out the body and just generate this: (defn wow-component [a b c d wow mate])
.. it shows be this:
test.clj::: error: unsupported binding form a │
test.clj::: error: unsupported binding form b │
test.clj::: error: unsupported binding form c │
test.clj::: error: unsupported binding form d │
test.clj::: error: unsupported binding form wow │
test.clj::: error: unsupported binding form mate │
linting took 13ms, errors: 6, warnings: 0
wonder if there's something about those vars which is not visible when api/sexpr
is run on it, printing raw one second
(def wow-component (fn [a b c d wow mate])) │
<list: (def wow-component (fn [a b c d wow mate]))> │
test.clj::: error: unsupported binding form a │
test.clj::: error: unsupported binding form b │
test.clj::: error: unsupported binding form c │
test.clj::: error: unsupported binding form d │
test.clj::: error: unsupported binding form wow │
test.clj::: error: unsupported binding form mate │
test.clj::: error: unsupported binding form a │
test.clj::: error: unsupported binding form b │
test.clj::: error: unsupported binding form c │
test.clj::: error: unsupported binding form d │
test.clj::: error: unsupported binding form wow │
test.clj::: error: unsupported binding form mate
<list: (defcomponentk wow-component [[:data a b c d] [:state wow mate]] (display-name [_] "Lol") (component-did-mount [_]) (render [_] (+ a b c d wow mate)))>
I am sorry @U04V15CAJ but I am an idiot 🙂 .. While I was prepping this for you I found the mistake, I was converting a vector-node to a vector using (api/sexpr)
but then adding it back in, I wasn't mapping to tokens back into token-nodes, basically went from:
(api/vector-node flattened)
;; to this ->
(api/vector-node (map api/token-node flattened))