On 25.01.2009, at 21:33, Rich Hickey wrote: > Looks interesting. I made AStream.Iter an IFn, so you can try that.
Thanks! It works fine, the changes to stream-utils are checked in. There is just one situation that still requires a wrapper: it is not possible to make a stream directly from a stream-iter: (take 10 (stream (stream-iter (int-stream)))) java.lang.IllegalArgumentException: Don't know how to create ISeq from: Iter (NO_SOURCE_FILE:0) I suppose stream tries conversion to seq before trying the generator interface. > One thing I would say is that, e.g. drop-first is eager - it drops the > items from the source stream on creation. Streams will let us write > things like drop fully lazily, and that should be the norm. Indeed. drop-first is a bit of a quick hack I used for testing, to be replaced by a more general index-based selection operation that extracts a sub-stream specified by first/step/last, and that one would necessarily be lazy. Something else that would be nice for implementing generators and thus streams is Scheme-style continuations. That would permit to write generators like in Python, as loopy code with "yield" calls inserted where a value should be produced. This could probably be implemented in the form of a continuation monad, but I am not sure the performance would be great. Did you ever consider providing continuations directly as a language feature? Assuming of course that the JVM permits it, which I am not sure about. Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---