Pls advice on rewriting a macro to sci 🙏 I am rewriting https://github.com/fulcrologic/fulcro/blob/main/src/main/com/fulcrologic/fulcro/react/hooks.cljc#L179-L188 (and use-effect) macro - what gives me trouble is that the original impl refers to itself, and to the other macro. How do I make such as recursive impl correctly? The simpler case:
1 (ns sci.configs.fulcro.react.hooks
2 (:require [com.fulcrologic.fulcro.react.hooks :as hooks]))
3 (defn ^:sci/macro use-lifecycle
4 ([&form &env setup] `(use-lifecycle &form &env ~setup nil)) ; FIXME Is this correct self-ref for a sci macro?
5 ([&form &env setup teardown] ... `(use-effect ...))
At line 4, when the macro invokes its other arity, should I have what I do, or (sci.configs.fulcro.react.hooks/use-lifecycle &form &env (hooks/use-lifecycle com.fulcrologic.fulcro.react.hooks/use-lifecycle . So if it makes a simple replacement in that context, then it macroexpands that again in the same context, then perhaps the last one is correct?? 🙏The expansion should return the same as in clojure. the form and env are always inserted by the compiler/interpreter
but note that when you expose it as com.fulcrologic.fulcro.react.hooks/*** you should return this explicitly in the expansion or via the alias
so probably
`(hooks/use-lifecycle ~setup nil)
is what you wantelse SCI tries to evaluate (sci.configs.***) which isn't exposed
That makes sense, then you!