Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clojure sequence type

What's the correct type of a sequence? I have this code:

(defrecord MethodInfo [^clojure.lang.ISeq preconds ^clojure.lang.ISeq postconds])

But it doesn't seem to correctly enforce the type requirements, since I can write (new MethodInfo 1 2).

like image 719
gatoatigrado Avatar asked Jul 17 '11 23:07

gatoatigrado


1 Answers

My understanding is that Clojure's Type Hints are only there for performance reasons, to improve method lookup by side-stepping reflection; That is their only purpose, and not to enforce static types in a dynamic language.

Please see this answer to a similar question.

Edit:

There is talk of being able to enforce primitive return types in some cases in Clojure 1.3, but this is clearly something that's in flux, and still wouldn't apply to sequence types.

like image 71
Scott Avatar answered Sep 23 '22 12:09

Scott