Clojure static typing, part 2

This is a continuation of my previous question on static typing of Clojure.

I looked at the Java source code for the compiler, and there are several places where it checks the value *warn-on-reflection*, but when I compile the following code, I get only an error at runtime:

(defn div-2 [^String s] (/ 2 s))

Are there any circumstances under which this code should not give a compilation warning (this is not the case)? How difficult it would be to give the compiler a warning about the following code:

(defn get-length [^String s] (.length s))
(defn test-get-length [] (get-length 2.0))

Thank.

+3
source share
3 answers

, def 'd vars. , . ? , .

"", , . vars, vars, .. /, , ...

Clojure - ( , .)

, , , , . Clojure .

+3

, , , Clojure ? , Clojure. , .

, , .

+2

, , clojure (, Dart ..). : Typed-Clojure

- ...

+1

Source: https://habr.com/ru/post/1775420/


All Articles