Skip to content
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

Quoting body of op macro #2

Open
vitvly opened this issue Oct 19, 2015 · 2 comments
Open

Quoting body of op macro #2

vitvly opened this issue Oct 19, 2015 · 2 comments

Comments

@vitvly
Copy link

vitvly commented Oct 19, 2015

Hi Vitaliy,

last week i ran into a weird issue when trying to deploy the jar using mixfix via lein uberjar. This StackOverflow issue summarises the essence of it.

Basically, it seems that op macro modifies a global *lang* and therefore fails when run from an uberjar, as in that case contents of the global remain unchanged. As per Leonid Beschastny's comment, do you think it is possible to modify the definition of the op macro by prepending syntax-quote to its body? It would then transform to:

(defmacro op
  "Defines mixfix operator. First optional argument is a name for the
   operator's scope. The second is precedence level of the operator. The bigger
   the number the tightly the operator binds. The third is resulting form head
   symbol. And the last one is a mixfix picture of the operator."
  ([lang prec symbol picture]
    `(binding [*lang* @(resolve &env lang)] (add-op prec symbol picture) nil))
  ([prec symbol picture] `(add-op prec symbol picture) nil))

My knowledge of macros is quite limited, so I apologise if this modification seems like nonsense to you.

Thanks,
Vitaliy.

@awto
Copy link
Owner

awto commented Oct 19, 2015

Hi Vitaliy

Absence of syntax quote is critical there, as it is compile time variable. It will work with it on Clojure but won't on ClojureScript unfortunately, since there they are 2 separate stages. I haven't tried building uberjars with the library, I will try to find some solution, thanks for report.

Regards, Vitaliy

@vitvly
Copy link
Author

vitvly commented Oct 20, 2015

Thank you! For now I'm following the dynamic require approach as outlined in the accepted StackOverflow answer, and it works with an uberjar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants