Fork me on GitHub
#cljs-dev
<
2019-11-15
>
mfikes01:11:16

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

dnolen13:11:43

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

mfikes16:11:55

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

mfikes20:11:48

Thanks for the fix!

dnolen20:11:53

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

👍 2
mfikes20:11:46

I've unleashed Canary on master

lilactown21:11:00

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?

mfikes21:11:58

Canary's green

dnolen21:11:26

@lilactown you shouldn't have to do anything

dnolen21:11:41

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

lilactown21:11:50

I would like to help with making it better as well

dnolen21:11:01

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

dnolen21:11:11

no user level code changes at all

lilactown21:11:27

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

mfikes21:11:30

@lilactown Kevin Lynagh has explored this space

lilactown21:11:51

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

lread21:11:09

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.

lread21:11:16

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

lilactown21:11:34

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

mfikes21:11:59

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

lilactown21:11:16

is there any public API for it yet?

mfikes21:11:10

No... ilk also uses similar private API FWIW

lilactown21:11:52

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

lilactown21:11:52

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

lilactown21:11:22

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