Iterators on Clojure's collections should follow the expected JDK behavior of throwing NoSuchElementException on next() when an iterator is exhausted. Current collections have a variety of other behaviors.
Issue encountered in real world code using http://pipes.tinkerpop.com.
This throws a NPE instead of NSEE.
This throws an ArrayIndexOutOfBoundsException instead of NSEE.
An additional problem found during testing is that subvecs will iterate past the subvector end and produce data from the underlying source vector:
Approach: The attached patch fixes the methods by adding a check for hasNext before actually trying to provide the next element. If there is no next element the correct exception is thrown.
Patch: clj-1453-3.patch and tests: CLJ-1453-tests.patch