In principle you could use method_exists to check whether the start, next & done are defined for a particular type to make the isiterator function. In practice this may run into https://github.com/JuliaLang/julia/issues/8959 which should be fixed with https://github.com/JuliaLang/julia/pull/18457 .
So until then this is not 100% possible. (Well, Traits.jl could do it, but one of the main reasons that package never made it passed experimental-status is indeed the difficulty to work around issue 8959) If you need this now, use SimpleTraits.jl, follow above approach and advise your users to manually add or remove types from the IsIterable trait if method_exists hits 8959. Let me know if you need help. Mauro On Wed, 2016-10-19 at 19:57, David Anthoff <anth...@berkeley.edu> wrote: > Is there some way to find out whether a type can be iterated? I'm looking > for something like `isiterator(IterType)`, that would return `false` from a > default implementation and which any type that actually supports the > standard iterator interface would return `true`. > > > > If we had that, we could actually define a SimpleTrait ``IsIterator`` and > use method dispatch to have methods that operate on iterators, which would > be really powerful. > > > > Cheers, > > David