Iterators.jl icon indicating copy to clipboard operation
Iterators.jl copied to clipboard

review iteratorsize for all types

Open CarloLucibello opened this issue 9 years ago • 4 comments

as it was done in #85 for Chain

types: Product, Partition, IMap, Iterate (IsInfinite)

CarloLucibello avatar Oct 18 '16 07:10 CarloLucibello

I suggest that before adding more iteratorsize support, a final julia v0.4 version be tagged, and the REQUIRE file be updated to need julia 0.5

Iteratorsize is generally functional for 0.4, in its current state, and keeping it compatible makes this in particular much harder

oxinabox avatar Oct 18 '16 09:10 oxinabox

I run into the following problem:

julia> nth(drop(repeatedly(() -> 1), 1), 1)
ERROR: MethodError: no method matching length(::Iterators.RepeatCallForever)
Closest candidates are:
  length(!Matched::SimpleVector) at essentials.jl:168
  length(!Matched::Base.MethodList) at reflection.jl:256
  length(!Matched::MethodTable) at reflection.jl:322
  ...
 in nth(::Base.Drop{Iterators.RepeatCallForever}, ::Int64) at /home/philipp/.julia/v0.5/Iterators/src/Iterators.jl:497

Since this seems to be due to this line: is this an instance of this issue? Because I can replicate it with

julia> applicable(length, drop(repeatedly(() -> 1), 1))
true

julia> length(drop(repeatedly(() -> 1), 1))
ERROR: MethodError: no method matching length(::Iterators.RepeatCallForever)
Closest candidates are:
  length(!Matched::SimpleVector) at essentials.jl:168
  length(!Matched::Base.MethodList) at reflection.jl:256
  length(!Matched::MethodTable) at reflection.jl:322
  ...
 in length(::Base.Drop{Iterators.RepeatCallForever}) at ./iterator.jl:371

julia> Base.iteratorsize(drop(repeatedly(() -> 1), 1))
Base.IsInfinite()

and I think that checking for IsInfinite somehow should prevent this. But I might also have understood the logic wrong, and the behaviour is due to length...

phipsgabler avatar Apr 04 '17 17:04 phipsgabler

@phipsgabler Please file that separately and I'll fix it today :)

iamed2 avatar Apr 04 '17 18:04 iamed2

@iamed2 done: #100. Thanks!

phipsgabler avatar Apr 04 '17 18:04 phipsgabler