Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I believe you are wrong about optional static typing; type hints in clojure are purely an optimization and for clarifying dispatch:

   user=> (defn foo [^Integer i] (prn (type i)))
   #'user/foo
   user=> (foo 1)
   java.lang.Integer
   nil
   user=> (foo [1])
   clojure.lang.PersistentVector
see also: http://clojure.org/java_interop#Java%20Interop-Type%20Hints


right you don't get type-checking only type-hinting for performance.


In Common Lisp we have optional type declarations, and a common strategy for implementations (for SBCL, say) is to treat such declarations as assertions by default, leading to more safety, and for performance-sensitive parts of the code you can "(locally (declare (optimize speed (safety 0))))", which makes the type declarations act as performance optimizations for that part of the code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: