> My lazy-sequence implementation was exactly following SICP: while 
> theoretically pure and good, might not be the best in practice, so I believe 
> your implementation can be much better.
> 
> Major performance boost in stateful implementation compared to lazy-sequence 
> with delay and force comes from removing essentially cancelling each other 
> delays and forces. Haskell has stream-fusion that implements this idea 
> differently and with the help from compiler, but creates absolutely seamless 
> interface to Haskell-lists — they’ve done very clever work.
> 
> The disadvantage of stateful streams is their complete opaqueness, as at 
> every stage all they are is just a promise to do the computation.

Yes, I think adding state to streams is probably adding an unnecessary level of 
complexity (and as you've mentioned, opaqueness) to the system, but the points 
you've raised are valid. I think it would be well worth it to look into 
aggressively optimizing the stream implementation I use for my collections 
given that it serves as the basis for a large number of operations.

As for fusion, yes, that's a very neat optimization, though obviously not 
entirely practical in a language like Racket. It might be worth exploring the 
“transducers” approach taken by Clojure 1.7, which generalizes a number of 
sequence operations to avoid creating intermediate streams (and can coexist 
peacefully with the more traditional sequence operations).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to