-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal example #1
Comments
There's obviously nothing in macrovitch you can't do by hand. Its goal is to alleviate the pain of making code work in Clojure and the two Clojurescript flavors. I created these macros to help porting xforms from clj to cljs and self-hosted cljs. I encountered two issues:
Determining the stageIn Clojure there's none, so it's always the right time to run some code. In Clojurescript, it's easy: just use reader conditionals (like you did in your example). In self-hosted Clojurescript: the file is going to be evaluated twice (once in pseudo
Determining the target dialectThis problem is specific to Clojure and clojure-hosted Clojurescript: as macros definitions are read by Clojure in both cases, for any reader conditional inside the macro definition this is the As a macros can be invoked from Clojure or Clojurescript the target dialect can't be determined statically. |
Thanks @cgrand for the detailed explanations. Actually, I have tried to port several lib to be self-host compatible and it was very hard. The only one I was able to port successfully is core.match. Here is the JIRA ticket and the PR. But still I feel I need a concrete simple example that demonstrates the need for |
@viebel from a cursory glance at your PR, I think you have introduced some bugs when run under "regular" Clojurescript. I believe |
Thanks @cgrand. Could you write this remark in the jira ticket? |
And if I'm right it's an interesting case not covered (yet) by |
Having spent some time trying to make (defrecord FailNode []
INodeCompile
(n-to-clj [this]
(if *recur-present*
`(throw
(macros/case
:cljs
(js/Error. (str "No match found."))
:clj
(Exception. (str "No match found."))))
(backtrack-expr)))) and (defn backtrack-expr []
`(macros/case
:cljs
(throw cljs.core.match/backtrack)
:clj
(throw clojure.core.match/backtrack))) |
Hi @cgrand
macrovich
is a great tool that will help the clojure community to port a lot of clojurescript libs to bootstrap cljsFor instance datascript.
I’m really excited because it means that we will be able to have all those great libs running in the browser with klipse!
I started to play with
macrovich
But I’m a bit confused about what problem exactly macrovich solves
I have created a minimal repo
with two macro files:
without macrovich
with macrovich
File #1 seems to work fine in all 3 envs:
So in what (simple) cases do we need macrovich?
The text was updated successfully, but these errors were encountered: