core-async

2025-02-20T17:05:43.231909Z

Currently the documentation for flow/process in clojure.core.async.flow says it can receive a fn or a map and that the only required arities/keys are the :describe(arity 0) and :transform(arity 3) but this optionality seems only to be working when providing maps...

2025-02-20T17:06:09.599999Z

clj -Sdeps '{:deps {org.clojure/core.async {:git/sha "d922995579ce50f0760cbfc781f1e4a6ea077ce1" :git/url ""}}}'
Clojure 1.12.0
user=> (require '[clojure.core.async.flow :as flow])
nil

user=> (flow/create-flow {:procs
                          {:my-proc (flow/process
                                     (fn
                                       ([] {:outs {:nums ""}})
                                       ([_ _ _] [])))}})

Execution error (IllegalArgumentException) at clojure.core.async.flow.spi/eval9490$fn$G (spi.clj:11).
No implementation of method: :describe of protocol: #'clojure.core.async.flow.spi/ProcLauncher found for class: nil

2025-02-20T17:07:36.468169Z

it is confusing that the error says the describe isn't found while the zero arity is being provided

Alex Miller (Clojure team) 2025-02-20T17:08:15.585549Z

I’ll take a look at this today

2025-02-20T17:15:44.640039Z

great, the issue is still valid but my previous example is wrong, forgot the :proc keyword, this is the corrected one :

clj -Sdeps '{:deps {org.clojure/core.async {:git/sha "d922995579ce50f0760cbfc781f1e4a6ea077ce1" :git/url ""}}}'
Clojure 1.12.0
user=> (require '[clojure.core.async.flow :as flow])
nil
user=> (flow/start
 (flow/create-flow {:procs
                    {:my-proc {:proc (flow/process
                                      (fn
                                        ([] {:outs {:nums ""}})
                                        ([_ _ _] [nil []])))}}}))
Execution error (ArityException) at clojure.core.async.flow.impl$proc$reify__9924/start (impl.clj:258).
Wrong number of args (1) passed to: user/eval9998/fn--9999
so it looks like when you provide a fn it is calling all arities.

👍 1
Alex Miller (Clojure team) 2025-02-20T17:16:28.809689Z

I ran into this myself a couple days ago, hadn't gotten around to looking at it yet

👍 1
2025-02-20T17:19:59.441999Z

you need all the arities 0...3

2025-02-20T17:20:32.586509Z

yeah, that works, but then it doesn't match the documentation

Alex Miller (Clojure team) 2025-02-20T17:25:41.346629Z

the intent was to not need all the arities

👍 1