Base.drop seem to ignore that their argument iterator has
SizeUnknown(), which in turn makes
collect(take(...)) crash with “MethodError: no method matching length” when there in fact is no length method for the argument. I found related issues from 2015, when I think
Base.iteratorsize was not there yet, but is this still an issue, or am I doing something wrong here?
I’m playing with the precompiled Julia 0.5.0 (64-bit generic Linux) binary to see how well the new generator machinery now works. The point of this test case is that it has random length.
module GenerationExploration export Pool import Base: start, done, next, iteratorsize immutable Pool ; data end Base.start(pool::Pool) = nothing Base.done(pool::Pool, state) = rand(1:10) == 1 Base.next(pool::Pool, state) = rand(pool.data), state Base.iteratorsize(::Pool) = Base.SizeUnknown() # julia> using GenerationExploration # # julia> Base.iteratorsize(Pool(['3', '1'])) # Base.SizeUnknown() # # julia> Base.iteratorsize(take(Pool(['3', '1']), 2)) # Base.HasLength() # # Why does Base.take think it HasLength() when a Pool clearly tells it # that it has not? end # module