This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-15
Channels
- # announcements (1)
- # aws (79)
- # babashka (47)
- # beginners (82)
- # calva (65)
- # cider (27)
- # cljdoc (18)
- # cljs-dev (29)
- # clojure (189)
- # clojure-dev (5)
- # clojure-europe (3)
- # clojure-italy (1)
- # clojure-madison (6)
- # clojure-nl (4)
- # clojure-spec (10)
- # clojure-uk (41)
- # clojured (3)
- # clojurescript (5)
- # clojurex (17)
- # cursive (30)
- # data-science (7)
- # datomic (17)
- # emacs (3)
- # events (6)
- # fulcro (2)
- # funcool (9)
- # graalvm (29)
- # jobs-discuss (3)
- # joker (3)
- # kaocha (6)
- # malli (5)
- # music (6)
- # off-topic (21)
- # reagent (3)
- # reitit (4)
- # rewrite-clj (8)
- # shadow-cljs (49)
- # spacemacs (7)
- # sql (23)
- # tools-deps (15)
- # vim (43)
- # xtdb (19)
The main ticket I think needs to be at least assessed is https://clojure.atlassian.net/projects/CLJS/issues/CLJS-3170
Inference regression related to Closure Library analysis: https://clojure.atlassian.net/browse/CLJS-3189
Release notes updated for a Monday release https://github.com/clojure/clojurescript-site/pull/332
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?
@lilactown you shouldn't have to do anything
and in fact I would discourage being interested in the details unless you're going to work on making it better 🙂
but there are parts of some library code I’m writing that would benefit from leveraging type inference to generate faster code
@lilactown Kevin Lynagh has explored this space
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.
cljs.analyzer/infer-tag
(got it from reading his hicada fork’s source code) was what I was looking for. thanks!
i’ll use ilk for now in the hopes that when a public API gets released it will get updated :<
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