[Issue 19587] std.range.generate's range calls its argument one time too many

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 6 22:53:27 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=19587

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel at live.nl
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Dennis <dkorpel at live.nl> ---
Just got hit by this today, my `generate!(() => readln()).take(10).array`
discarded the line after the 10 lines put into the array.

This is really annoying, but changing this would be a breaking change, so I'm
afraid the fix would be either:

- a template parameter 'caching' with default value of `true`
- a new synonym symbol, similar to `approxEqual => isClose`, with the
possibility to deprecate the old symbol (caching can still be achieved by doing
`generate!(f).cache`). I'm not sure what that synonym would be, things that
come to mind are `generateLazy`, `successiveCalls`, `repeatEvaluate`, but I'm
not a big fan of them.

--


More information about the Digitalmars-d-bugs mailing list