This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-27
Channels
- # bangalore-clj (1)
- # beginners (187)
- # braveandtrue (52)
- # calva (7)
- # cider (17)
- # cljs-dev (14)
- # clojure (27)
- # clojure-austin (4)
- # clojure-dev (11)
- # clojure-finland (4)
- # clojure-italy (5)
- # clojure-nl (1)
- # clojure-russia (22)
- # clojure-spec (9)
- # clojure-uk (27)
- # clojurescript (91)
- # datomic (40)
- # duct (4)
- # emacs (14)
- # figwheel-main (36)
- # fulcro (11)
- # hoplon (10)
- # immutant (9)
- # instaparse (4)
- # java (1)
- # jobs (2)
- # off-topic (28)
- # pedestal (1)
- # reagent (15)
- # reitit (7)
- # remote-jobs (6)
- # ring-swagger (3)
- # shadow-cljs (28)
- # slack-help (1)
- # spacemacs (4)
- # specter (1)
- # sql (3)
- # testing (3)
- # tools-deps (24)
11:26 $ clj
Clojure 1.9.0
user=> (set! *warn-on-reflection* true)
true
user=> (let [x :foo]
(if (string? x)
(.startsWith x "lol")
(prn x)))
Reflection warning, NO_SOURCE_PATH:4:4 - call to method startsWith on clojure.lang.Keyword can't be resolved (no such method).
:foo
nil
Sort of surprised me, since we know that the only way we can reach the (.startsWith...)
is if x
is a String
?
@schmee the reason I ask is because of the current cljs-tickets @mfikes has been working on, like https://dev.clojure.org/jira/browse/CLJS-2873, which indicates that there is type inference at play.
👍 4
Clojure only really does what I would call type propagation rather than inference, and only for Java interop.
It doesn’t do any flow/occurrence typing, which would be required for the (if (string? x) ...)
example.