Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-23 Thread Tom Locke
OK I've filed this here: http://dev.clojure.org/jira/browse/ASYNC-79 In trying to create a minimal test case I tried a trivial macro (defmacro my-case [expr cases] `(case ~expr ~@cases)) inside a go block, and that worked fine, so it's more subtle than just case in a macro is broken. I

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-23 Thread Daniel Kersten
Honestly, I'm against having core.async as anything other than a normal macro. The less built-in magic the better, plus its nice to know that almost everything I use, I could in theory build myself without hacking the language itself, should I ever want to. The more features that get special

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-23 Thread Daniel Kersten
*I meant to write clean architecture :-) On 23 July 2014 15:29, Daniel Kersten dkers...@gmail.com wrote: Honestly, I'm against having core.async as anything other than a normal macro. The less built-in magic the better, plus its nice to know that almost everything I use, I could in theory

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-22 Thread Tom Locke
Thanks for your reply. That's pretty much what I'd come to understand. I'm a bit puzzled why this restriction exists though. Of course function calls can't be resolved at macro expansion time, so it makes sense that ! ! inside functions can't be found. But I don't understand why the go macro

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-22 Thread Daniel Kersten
There's really two questions in there as I see it. 1. Why doesn't the go macro expand all nested macros. 2. Why can't the go macro find the ! and ! anyway I don't know the answer to either, unfortunately. Because macro expansion happens in reverse order to normal evaluation, nested macros aren't

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-22 Thread Kevin Marolt
Not sure if I understood the initial question correctly, but isn't the following sort of what you wanted? ;; == (require '[clojure.core.async :as async]) (defmacro dispatch-on [ch cases] (let [argssym (gensym args__) keysym (gensym key__) ressym (gensym res__)

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-22 Thread Kevin Marolt
I tried it in ClojureScript and I did get the same error as your did. I believe this is because the go-macro doesn't handle the case-statement correctly (or, rather, not at all). Switching from (case key ...) to (condp = key ...) however appears to do the trick (along with all the other awkward

[ClojureScript] core.async - restriction on macros inside go block?

2014-07-21 Thread Tom Locke
Hi All, I had a terrible time trying to write a convenience macro for reading from a core.async channel. The idea was to make it easier to do the common dispatch on first part of a message pattern, as in: (let [[msg args] (! my-channel)] (case msg :msg1 (let [[a b] args]