interop

adamfrey 2023-04-21T16:59:03.336219Z

Does it make sense to type hint a Java interface vs. a concrete class? I have clojure code that is going to be passed some sort of Iterable that I don't know ahead of time so I was wondering if I should do:

(let [^Iterable i (:val m)]
    ...
    (.size i))
to avoid reflection on the .size call.

Alex Miller (Clojure team) 2023-04-21T18:00:59.865539Z

Yes, usually better

Alex Miller (Clojure team) 2023-04-21T18:01:40.160599Z

Although Iterable doesn’t have a size method

adamfrey 2023-04-21T18:03:12.110069Z

Thanks. And also, good point.