-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
failure when try to define and subsequently call a macro in a try block #1086
Comments
Yes, |
I'm confused why this issue and issues like it keep coming up. This is not like any code I find myself typically writing so can you give me some context as to why such dynamic code is necessary? |
Thanks for taking a look. I'm writing a macro for remote Basilisp code execution in another process and encountering errors with syntax that seems valid but throws exceptions. The macro, in its simplest form for the purpose of illustration, wraps the remote code in a (defmacro with-remote-eval [& code]
`(try
~@code
(catch python/Exception e
e)))
(with-remote-eval
code) I consider this a valid macro use case. I've found a workaround for unsupported forms within (defmacro with-remote-eval [& code]
(let [[code-unsupported code-rest] (split-code code)]
`(do
~@code-unsupported
(try
~@code-rest
(catch python/Exception e
e))))) Let me know if these errors aren't worth reporting, and I'll adjust accordingly. Thanks |
I would say you can keep reporting such issues as you discover them, but I didn't really understand why you were doing this and now I do so thank you. I was just digging a bit more into this just to make sure I understood the problem. We can see it works for normal functions: (try (defn e [] :e) (e) (catch Exception _ nil)) ;; => :e But fails for macros as you noted. The reason for this is that the compiler generates an unbound I'm not exactly sure what kind of tricks Clojure uses to allow this, but it seems unlikely to be possible in Basilisp since we need to define the function before it can be used as a macro and that can't happen until compilation is done. I don't think |
Hi,
it doesn't seem to be possible to define and subsequently call a macro inside a try block
To reproduce,
open the nREPL and define and call a trivial macro inside a try block, it fails with the above error
The same works fine at the top level
Is there a technical constraint perhaps that prevents macros from being defined anywhere else other than the top level?
Thanks
The text was updated successfully, but these errors were encountered: