This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-29
Channels
- # babashka (99)
- # beginners (47)
- # calva (28)
- # cider (5)
- # clj-kondo (5)
- # clojure (2)
- # clojure-europe (11)
- # clojure-gamedev (1)
- # clojure-norway (5)
- # clojurescript (11)
- # clr (82)
- # conjure (13)
- # cursive (3)
- # datahike (1)
- # datomic (28)
- # emacs (11)
- # fulcro (43)
- # honeysql (10)
- # interop (17)
- # keechma (3)
- # pathom (27)
- # re-frame (1)
- # reagent (3)
- # reitit (18)
- # releases (1)
- # shadow-cljs (81)
- # vim (5)
- # xtdb (3)
Type hinting ..
chains to avoid reflection warnings.
(deftype B [c])
(deftype A [^B b])
(.. ^A a -b -c)
What is the most idiomatic way to write code like this which uses type hints? I still get reflection warnings if I try a few things I'd think would help.type hinting a ?
It is type hinted, the issue is that -c is emitting the warning since it's coming from a typedef
, and type hinting the typedef
fields doesn't appear to fix the issue here.
Should've been more clear in the original
Updated
do you mean deftype
?
yeah, sorry
been doing too much C lately
type hints in a deftype don't actually do anything in the record (other than ^long and ^double)
they are Object fields
right. I noticed that (.. ^A a ^B -b -c)
also didn't suppress the warning though
so in this case -b is of type Object and so that's not enough to help the compiler
without thinking too hard about it, I would expect hinting -b to work, so not sure if I'm missing something or there's a bug
does just using . work?
well, throw it on https://ask.clojure.org if you want me to look at it more, I'm headed offline
Sounds good, thanks for the help