I am a huge fan of Plumatic Schema, and it regularly helps me to find mistakes in my code early in the development process. However, I just tracked down a very unexpected error when using a lazy infinite list such as that produced by `(range)`
Suppose you define two simple functions like `clojure.core/first`. One doesn't use Schema and the other does: (defn show-1 [arg] (nth arg 0)) (s/defn show-2 :- s/Any [arg :- [s/Any] ] (nth arg 0)) (nl) (println "show-1") (spyx (mapv show-1 [ [:a :b :c] (range) ])) (nl) (println "show-2") (spyx (mapv show-2 [ [:a :b :c] (range) ])) The results of running this code are: show-1 (mapv show-1 [[:a :b :c] (range)]) => [:a 0] show-2 ERROR in (dotest-line-472) (Iterate.java:54) Uncaught exception, not in assertion. expected: nil actual: *java.lang.OutOfMemoryError*: Java heap space at clojure.lang.Iterate.next (Iterate.java:54) clojure.lang.RT.next (RT.java:706) ... Apparently, turning on Schema validations causes the input collection to be realized for `show-2` function call. I am generally not a big fan of (infinite) lazy seq's and don't use them much. However, this one came up during a simple unit test and really had me scratching the old noggin for quite a while..... I'm not sure if there is an easy way of enhancing Schema to avoid this problem, or if it is just something one needs to be wary of. Alan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.