for/stream can use #:break as advertised (fixes #1910)

This commit is contained in:
Milo Turner 2018-02-07 12:32:36 -05:00 committed by Ben Greenman
parent 390977c1de
commit 2e1a81b345
2 changed files with 12 additions and 5 deletions

View File

@ -62,4 +62,9 @@
(test 1 'for/stream (stream-first (for*/stream ([x '(1 0)]) (/ x))))
(test 625 'for/stream (stream-ref (for/stream ([x (in-naturals)]) (* x x)) 25))
(test '(0 1 2 3 4 5) stream->list (for/stream ([i (in-naturals)] #:break (> i 5)) i))
(test '(0 1 2 3 4 5) stream->list (for/stream ([i (in-naturals)]) #:break (> i 5) i))
(test '(0 1 2 3 4 5) stream->list (for/stream ([i (in-naturals)])
(define ii (sqr i)) #:break (> ii 30) i))
(report-errs)

View File

@ -317,10 +317,12 @@
(raise-syntax-error (syntax-e #'derived-stx)
"missing body expression after sequence bindings"
stx #'body))
#`(sequence->stream
(in-generator
(#,derived-stx #,stx () clauses
(yield (let () . body))
(values)))))]))
(with-syntax ([((pre-body ...) body*) (split-for-body stx #'body)])
#`(sequence->stream
(in-generator
(#,derived-stx #,stx () clauses
pre-body ...
(yield (let () . body*))
(values))))))]))
(values (make-for/stream #'for/fold/derived)
(make-for/stream #'for*/fold/derived))))