clojurescript 2026-05-15

So, with the new ClojureScript supporting async/`await`, is there a way to make an async anonymous function right now? I noticed that ^:async (fn [...] ) doesn't work

I ran into this this weekend, I had assumed (fn ^:async [] ...) would work. I ended up given the function a name, it did not occur to me to try putting it on the fn. Was it considered to also support it on the argument vector?

The closest prior art to this was (^:once fn []) in JVM Clojure. Arg vec meta is usually dedicated to "what does this specific arity" do or return. CLJS does not support making one arity of a function async and another sync.

I'm writing some docs now

funnily enough I also ran into this weekend, but found it documented in SCI: https://github.com/babashka/sci/blob/master/doc/async-await.md#anonymous-async-functions 😄

@borkdude I left feedback on the PR, mostly looks good

merged!

🎉 1

Yes, the metadata needs to be on the fn symbol or on the name of the fn

We explicitly did not allow it to be on the form since this leads to MetaFns

I can't believe that I tried putting the metadata everywhere except this place 😆 . Thanks!

(BTW, async is so much better to use!)

@dnolen we should probably document this

@borkdude if you want to put together some kind of material for the website that would be great. perhaps w/ the interop content?

or anyone really 🙂

@dnolen tbh I think your blog post just needs an anon fn example and then you could just copy paste that to the website more or less

or link to the blog post from the website

updating blog is ok, but we need actually documentation on the interop page too.

is this also via JIRA?

I don't have any problems w/ PRs for the clojurescript-site for these changes

👍 1

added a quick syntax ref to the api site: https://cljs.github.io/api/syntax/#async-tag

👍 1

cljs.user=> ((fn ^:async _ []))
#object[Promise [object Promise]]

(^:async fn [] ...) I think? as in actually anon