I understand the pragmatism of your approach, but it's really
unfortunate. Seqs are a really convenient abstraction, and the ability
to model arbitrarily large or infinite ones (with laziness) is really
useful. In my opinion, only using seqs when all of the data can be fit
into memory really undermines the value of the abstraction (by
narrowing its usages so severely), and also makes laziness far less
useful (except possibly as a way to amortize costs over time, rather
than as a way to model infinite things).

This path has been well-tread, but the danger of hanging on to the
head of the list is due to the caching behavior of lazy seqs, which is
important for consistency - otherwise, walking the same seq twice
might result in different results.

As with most engineering efforts, there are trade-offs, but I've been
willing to accept the extra caution I need to employ when dealing with
lazy seqs. I've run into a few of these kinds of bugs over time, and
I'm guessing it's generally because in my uses, I'm dealing with
millions of records, and far more data than I can fit in memory. I'm
not sure that this indicates that seqs are the wrong tool in this
instance (as you seem to say), but the answer isn't clear to me.

On Nov 3, 1:20 pm, Brian Hurt <bhur...@gmail.com> wrote:
> We finally said "don't use a seq unless you don't mind all the elements
> being in memory!" and wrote a producer class.  The producer class is similar
> to a normal Java iterator, in that getting the next element updates the
> state of the object- however maps and filters are applied lazily, and there
> is an additional close function which says that no more elements need to be
> produced (allowing for the closing the underlying file descriptor, for
> example).
>
> I disbelieve in golden hammers.  Seqs (aka lazy lists) are incredibly useful
> in a lot of places, and I'm glad that Clojure has them.  On the other hand,
> there are times and uses where seqs are the wrong tool to use.  Of course,
> the same can be said of producers.

--~--~---------~--~----~------------~-------~--~----~
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