Well, I guess.
But I get the feeling that the iterator are probably coming from some java
object somewhere, and might get passed around in that environment, that's
why I'm worried.

In the examples you mentioned, line-seq for example. The reader has already
'escaped' since it is passed as an argument. Of course, it is perfectly fine
to have a function where the object is completely confined, read-lines[1] in
contrib comes to mind.

Functions like line-seq and resultseq-seq are obviously needed somewhere.
However, If they are used in conjunction with some java somewhere
else...well, I don't like it.

Jonathan

[1]
http://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/read-lines

On Sat, Jul 9, 2011 at 4:27 PM, Stuart Halloway
<stuart.hallo...@gmail.com>wrote:

> I don't think I like the notion of a lazy-seq and an iterator, since
> reading the iterator also changes it. Consider the case where you create a
> lazy-seq from an iterator, and the iterator somehow escapes. Somewhere else
> the iterator is read from, and now the data that where supposed to be in the
> lazy-seq no longer exists.
>
> I guess you could clone the iterator, but that would sort of remove the
> purpose of using a lazy-seq in the first place.
>
> Jonathan
>
>
> The same argument could apply to every other kind of lazy seq:
>
> * resultset-seq better not let the ResultSet escape
> * seqs over arrays better not let the array escape
> * line-seq better not let the BufferedReader escape
>
> and so on.
>
> Implementers of seqs are responsible for encapsulating implementation
> details and not letting them escape. It's a fact of life.
>
> Stu
>
>
> Stuart Halloway
> Clojure/core
> http://clojure.com
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to