What an impressive amount of work. In fact, I think it might be a bit
too impressive. I would find this all easier to comprehend and use if
it were split into two SRFIs, one with the basic operations and another
with all of the utilities that build upon them. The basic one could
contain something like:
STREAM-NULL
STREAM-CONS
STREAM
STREAM?
STREAM-NULL?
STREAM-PAIR?
STREAM-CAR
STREAM-CDR
STREAM-MAP
STREAM-FOR-EACH
Did you consider using more perspicuous, if less traditional, names?
STREAM-NULL -> EMPTY-STREAM
STREAM-CONS -> MAKE-STREAM
STREAM-NULL? -> EMPTY-STREAM?
STREAM-PAIR? -> NONEMPTY-STREAM?
STREAM-CAR -> STREAM-HEAD
STREAM-CDR -> STREAM-TAIL
Finally, I don't understand why STREAM-DEFINE in the reference
implementation is not just defined as
(define-syntax stream-define
(syntax-rules ()
((stream-define spec body0 body1 ...)
(define spec
(make-stream
(delay (force (stream-promise (begin body0 body1 ...)))))))))
If there is a reason for the current definition, you could remove its
final pattern
(stream-define (name args ...) body0 body1 ...)
because everything that matches this is already matched by the previous
pattern
(stream-define (name . rest) body0 body1 ...)
-Richard Kelsey