Re: make-for-each-generator
Sudarshan S Chawathe 11 Nov 2015 14:42 UTC
Shiro Kawai wrote:
> While I'm preparing manual entries for srf-121, I felt I need to add the
> following
> description to make-for-each-generator:
>
> >>
> If obj is mutated before the returned generator walks all the values, the
> behavior depends on how the for-each procedure handles the situation;
> it may or may not be a safe operation. In general it's better to avoid
> mutation until the generator returns EOF. Once the generator is exhausted,
> though, it is safe to mutate obj.
> <<
>
> Is this worth including to srfi document? It may be implied, but
> how mutation interacts with already exhausted behavior may not be obvious.
I would second the suggestion to add some clarification on the effects
of mutations occurring before and after a generator is exhausted.
On a related note, the description for the procedure list->generator
(and others like it) includes the statement:
Mutating the underlying object will affect the results of the
generator.
Unless there is a need to leave the effect unspecified, it would be nice
to indicate how mutation will affect each such procedure. (I suppose
the answer may be different for different object types, and it may get
messy.) Still, it is not clear to me how (if) I may be able to mutate
the underlying object while using the generator.
Regards,
-chaw