Re: Error detection of 'end' parameter in list->stream / list->generator
Peter McGoron 25 Jul 2026 14:40 UTC
> If we need to check end <= length condition eagerly, we need to scan
im-list, which kind of defeats the purpose of list->stream /
list->generator.
I recently modified my sample implementation to have this behavior. The
rationale is is that the procedure should raise an exception given
malformed data, and the easiest place to detect that is at the site
where the stream/generator is constructed. It's fairly simple to write
your own more optimized list->stream / list->generator.
> Gauche's list->generator already takes optional start/end, and it
handles the termination condition as "either 'end' index is reached or
the list is exhausted". In other words, 'end' works as the upper bound.
It might be better to take that approach. However, it could be the cause
of subtle bugs, as now instead of an error being reported somewhere, it
is simply never reported.
-- Peter McGoron