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)
.
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)
.
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.
© 2022 - 2024 — McMap. All rights reserved.