clojurescript

mauricio.szabo 2026-05-15T04:17:00.792409Z

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

plexus 2026-05-18T08:28:43.828739Z

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?

borkdude 2026-05-18T08:51:21.618819Z

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.

borkdude 2026-05-18T10:16:05.124479Z

I'm writing some docs now

Zatura24 2026-05-18T10:25:43.171539Z

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 😄

dnolen 2026-05-18T11:30:16.710969Z

Thanks!

dnolen 2026-05-18T12:40:08.033229Z

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

borkdude 2026-05-18T13:14:26.181059Z

done

dnolen 2026-05-18T14:01:19.849699Z

merged!

🎉 1
borkdude 2026-05-15T07:11:32.043039Z

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

borkdude 2026-05-15T07:12:13.647019Z

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

mauricio.szabo 2026-05-15T14:15:13.228779Z

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

mauricio.szabo 2026-05-15T14:15:37.761619Z

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

borkdude 2026-05-15T14:17:58.694659Z

:)

borkdude 2026-05-15T14:18:18.436769Z

@dnolen we should probably document this

dnolen 2026-05-15T16:47:34.096969Z

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

dnolen 2026-05-15T16:47:48.951909Z

or anyone really 🙂

borkdude 2026-05-15T17:38:09.019959Z

@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

borkdude 2026-05-15T17:38:22.428759Z

or link to the blog post from the website

dnolen 2026-05-15T18:04:35.172579Z

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

borkdude 2026-05-15T18:05:19.731999Z

is this also via JIRA?

dnolen 2026-05-15T18:16:31.548429Z

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

👍 1
shaunlebron 2026-05-16T05:14:12.409319Z

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

👍 1
p-himik 2026-05-15T04:36:28.597849Z

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

thheller 2026-05-15T06:20:45.722349Z

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