Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.async by

Interaction between core.match clauses and the core.async transform is undesirable. core.async should respect some hook so that some forms are left alone. For example:

(match [x y] [1 2] ... [3 4] ...)

All code generated for {{[1 2]}} and {{[3 4]}} would have this metadata attached to it.

4 Answers

0 votes
by

Comment made by: richhickey

Can you be more specific? This seems like a bad idea, and I wonder why it's desired.

0 votes
by

Comment made by: dnolen

To show how bad the interaction is between core.async and a library like core.match that also generates a lot of code consider the following:

`
(defn foo [e]
(match [e]

[{:type :mouse :client-x x :client-y y}] [x y]
[{:type :mouse :page-x x :page-y y}] [x y]
[{:type :touch :page-x x :page-y y}] [x y]
[{:type :key :char-code c}] c))

`

Without core.async, core.match produces a reasonable amount of code for this typical use of core.match to efficiently match maps - ~230 lines of pretty printed JavaScript.

But if the user wraps this typical expression in a go block:

`
(defn foo [in]
(go (while true

    (let [[e c] (<! in)]
      (match [e]
        [{:type :mouse :client-x x :client-y y}] [x y]
        [{:type :mouse :page-x x :page-y y}] [x y]
        [{:type :touch :page-x x :page-y y}] [x y]
        [{:type :key :char-code c}] c)))))

`

It generates nearly 4200 lines of pretty-printed JavaScript. I fail to see the value of core.async transforming the optimized conditionals generated by core.match, it just generates 18X more code and the extra generated code is obviously useless - a user is matching a value, they cannot put arbitrary computations in the patterns.

https://gist.github.com/swannodette/7723758

0 votes
by

Comment made by: metametadata

I still run into this issue and have to use the {{:jvm-opts}} workaround from https://github.com/emezeske/lein-cljsbuild/issues/303. In my case the StackOverflow also seems to be connected to {{is}} in combination with {{core.async}} and {{try-catch}}.

0 votes
by
Reference: https://clojure.atlassian.net/browse/ASYNC-40 (reported by dnolen)
...