Re: Comments on SRFI 121 Draft 8 (2015/11/08).
Sudarshan S Chawathe 09 Nov 2015 03:24 UTC
John Cowan wrote:
> > * gselect: One may expect the following to yield (a d e g h), but
> > the sample implementation yields (a d e h) instead (not
> > unreasonably). Regardless of which option is chosen, some
> > clarification would be helpful.
> >
> > (let ((g (list->generator '(a b c d e f g h))))
> > (append
> > (generator->list (gselect g
> > (list->generator '(#t #f #f #t #t #f))))
> > (generator->list g)))
>
> This expression is undefined by the rules of Scheme, because its result
> depends on the order of evaluation of the arguments of `append`. The
> procedures aren't ambiguous, it's depending on the order of side effects
> to the generator without using `begin` to sequence them that's ambiguous.
Oops; you are right, of course! In my haste to write convert my rough
testing history into a self-contained example, I goofed up.
However, I think the following modified version still exhibits the main
issue:
(let* ((g (list->generator '(a b c d e f g h)))
(x (generator->list
(gselect g
(list->generator '(#t #f #f #t #t #f)))))
(y (generator->list g)))
(append x y))
Regards,
-chaw