Looks like it might be appropriate to make the `stream` in `Eachline` be
the state of the iterator (instead of the `nada` returned by `next`).
Opening an issue (perhaps with a PR of a fix) could be the next step.
Unless someone finds some other logic for keeping `Eachline` the way it is.
On Friday, April 22, 2016 at 7:09:13 AM UTC+3, Lyndon White wrote:
>
> I am writing some iterators that work with `IO`.
>
> I thought, so that my iterators would not mutate,
> I would `deepcopy` the IO item, and store it as part of my state.
> (then only my state would mutate, and no-one cares probably (unless they
> were trying to `tee` for free))
>
> But `deepcopying` IO items apparently does not actually cause them to
> become separate.
> At least not for IOStreams.
>
>
>
> io=open("./data/text8/text8","r")
> ia = deepcopy(io)
> >IOStream(<file ./data/text8/text8>)
>
>
> position(io)
> >0
>
> position(seekend(io))
> >100000000
>
> position(ia)
> >100000000
>
>
>
> I was under the assumption that iterators never mutated, as there is no
> `!` in `next`.
> (then again there is also no `!` in `seekend`)
>
> So I was a bit stuck for how to implement.
>
> So I thought I would see how `Eachline` is implemented.
> <https://github.com/JuliaLang/julia/blob/master/base/io.jl#L356>
> It is mutating.
> So maybe my assumptions are wrong, and iterators can be mutating?
> They would be a lot easier to write that way, I guess.
>
> But julia does not have a `tee` function
> <https://docs.python.org/2/library/itertools.html#itertools.tee>
>
>
>
>