Tensegritics / Tensegritics/ClojureDart
Macros defined in ClojureDart cannot reference previously defined functions in same namespace
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.6k
- Forks
- 119
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Clojure dart is not able to handle this scenario where a function is defined and used in a subsequent macro.
To Reproduce
(defn gensyms [amt]
(vec (repeatedly amt gensym)))
(defmacro mk-comp-navs []
;; rest of fn altered for brevity...
(gensyms 1)
)
Syntax error compiling at (test.cljd:14:3).
Faulty form (defmacro mk-comp-navs [] (gensyms 1))
Expected behavior
This should work.
No doubt because of ClojureDart's two phase macro-expansion, it's not aware of the function defined a few lines above.
This is something that is possible in cljs, so presumably the two phases need to work more in parallel than in sequence, or effectively behave as such.
Assume you're aware of cljs quirks https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html
but these require defining aliases etc.
Additional context
I was trying to convert the specter library and came across a problem running the following code.
Pointing cljd at more clj code will highlight more differences with the language. More reason to champion the following suggestion ;-)
https://clojurians.slack.com/archives/C03A6GE8D32/p1729680676173319
I suggest this difference go under the Completeness status of the project given the difference with Clojure core.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure in test.cljd using the shown function and macro definitions, then inspect ClojureDart's two-phase macro-expansion path. Compare the behavior with the referenced ClojureScript macro case and the specter util_macros.clj example; done means a same-namespace function can be referenced from a subsequent macro without the reported syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100