-
Notifications
You must be signed in to change notification settings - Fork 53
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
Problems with defsfn #45
Comments
Thanks, even in a simple |
Hello @circlespainter, Thank you for your answer. I didn't understand your advice. When you say to avoid the re-definition of the var in the original (defmacro defsfn
"Defines a suspendable function that can be used by a fiber or actor.
Used exactly like `defn`"
[& expr]
`(do
(defn ~@expr)))) It would be a normal The way things are right now, I'm new to Pulsar, so I apologize if I'm getting something wrong or mixing things up. Best regards. |
Sorry, I didn't explain thoroughly. I mean this: (defmacro defsfn
"Defines a suspendable function that can be used by a fiber or actor.
Used exactly like `defn`"
[& expr]
`(do
(defn ~@expr)
(suspendable! ~(first expr)))) This is enough for me to make it work in the REPL and to fix your example while still having the testsuite fully ok. |
Hi @circlespainter, It's working now. Thank you very much. There's only the situation with the Best regards. |
My pleasure! Would you mind opening a separate issue for |
Done. |
Thanks! |
I was running in the REPL some examples derived from this post:
http://yogthos.net/posts/2015-06-17-Using-Pulsar.html
Problem is, every time I redefined one of the suspendable functions (the ones created with defsfn), the -main method would hang, no matter which method was used (clojure.tools.namespace.repl/refresh, using CIDER commands, etc).
I've looked into the definition of the defsfn macro, and found the following:
It seems that there is some kind of weird bug/interaction going on (or maybe I'm extremely unlucky :D). Anyways, here is an alternative version that seems to correct the problem:
It might be a good idea to look up the actual fn* node instead of using zip/rightmost to make this macro more robust, but that is left as an exercise to the reader.
The code was tested in an Ubuntu 15.10 machine (Linux 4.2.0-18-generic #22-Ubuntu SMPx86_64 x86_64 x86_64 GNU/Linux) and a Mac using OSX El Capitan, both running JDK 1.8.0_66-b17, Clojure 1.7.0, pulsar 0.7.3 and quasar-core 0.7.3, with the same results.
Here is a gist with a sample project.clj, a sample test file and a bunch of tests adapted from the "def" tests in the main clojure repo:
https://gist.github.com/anonymous/dc9f501e8c52b3a7166c
I hope it helps.
The text was updated successfully, but these errors were encountered: