cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
mfikes 2019-11-15T01:00:16.316800Z

The main ticket I think needs to be at least assessed is https://clojure.atlassian.net/projects/CLJS/issues/CLJS-3170

dnolen 2019-11-15T13:36:43.317800Z

ah right ok - I think the others, esp. externs inference we'll leave for a follow up

mfikes 2019-11-15T16:04:55.318300Z

Inference regression related to Closure Library analysis: https://clojure.atlassian.net/browse/CLJS-3189

dnolen 2019-11-15T16:17:21.318500Z

thanks

mfikes 2019-11-15T20:37:48.319100Z

Thanks for the fix!

dnolen 2019-11-15T20:37:51.319300Z

yep

dnolen 2019-11-15T20:38:53.319700Z

unless anything else comes up I think that's it - let's shoot for Monday release

đź‘Ť 2
mfikes 2019-11-15T20:41:46.320200Z

I've unleashed Canary on master

mfikes 2019-11-15T20:47:08.320500Z

Release notes updated for a Monday release https://github.com/clojure/clojurescript-site/pull/332

lilactown 2019-11-15T21:03:00.323700Z

have a couple questions re: type inference. 1. what’s the best way to infer the type of a form when writing a macro? e.g. if I’m walking a form and come across (foo :bar), what’s the best way to ask the analyzer the potential return type? Docs would be helpful! 2. What’s the best way to annotate my functions or macros in order to get better type inference? Are there any docs on what’s supported / best practices?

mfikes 2019-11-15T21:09:58.324Z

Canary's green âś…

dnolen 2019-11-15T21:13:26.324500Z

@lilactown you shouldn't have to do anything

dnolen 2019-11-15T21:13:41.325100Z

and in fact I would discourage being interested in the details unless you're going to work on making it better 🙂

lilactown 2019-11-15T21:14:50.326600Z

I would like to help with making it better as well

dnolen 2019-11-15T21:15:01.327Z

most of these changes are about faster code w/ zero work

dnolen 2019-11-15T21:15:11.327400Z

no user level code changes at all

lilactown 2019-11-15T21:15:27.327800Z

but there are parts of some library code I’m writing that would benefit from leveraging type inference to generate faster code

mfikes 2019-11-15T21:17:30.329500Z

@lilactown Kevin Lynagh has explored this space

lilactown 2019-11-15T21:18:51.331Z

oh right, I forgot about that. he did that with hiccup parsing

mfikes 2019-11-15T21:18:53.331200Z

(This stuff https://kevinlynagh.com/notes/fast-cljs-react-templates/)

lread 2019-11-15T21:19:09.331300Z

I am happy to give an overview of how canary->release works here https://clojurescript.org/community/dev once I understand it (maybe under https://clojurescript.org/community/patches). Would be a good place to set expectations (remind contributors this is oss and folks have day jobs) for how patches might (or might not) get to production.

lread 2019-11-15T21:20:16.331900Z

unless it is already described somewhere? I might have a blind spot!

lilactown 2019-11-15T21:20:34.332200Z

cljs.analyzer/infer-tag (got it from reading his hicada fork’s source code) was what I was looking for. thanks!

mfikes 2019-11-15T21:22:59.334700Z

Yeah, his stuff ended up using private API (an experiment, really)

lilactown 2019-11-15T21:23:16.334900Z

is there any public API for it yet?

mfikes 2019-11-15T21:24:10.335300Z

No... ilk also uses similar private API FWIW

lilactown 2019-11-15T21:38:52.335900Z

i’ll use ilk for now in the hopes that when a public API gets released it will get updated :<

lilactown 2019-11-15T21:44:52.340400Z

FWIW the kinds of optimizations I want to do:

(let [props (merge {:foo "bar"} {:baz 42})]
  (dom/div props "foo"))
and the dom/div macro can infer that props is a map another optimization, with React hooks:
(let [click-handler (fn [e] (js/alert "hi"))]
if a macro could infer that the right-hand side (fn ...) is a function type, and rewrite it to wrap in a useCallback:
(let [click-handler (react/useCallback (fn [e] (js/alert "hi")) #js [])]
which would preserve identity of the function across renders, allowing for other optimizations

lilactown 2019-11-15T21:46:22.341100Z

I’m not sure if all cases can be inferred right now that I’m interested in, but I’d like to help get there if I can