Thread overview
[Issue 19587] std.range.generate's range calls its argument one time too many
May 06, 2021
Dennis
May 06, 2022
Remi Thebault
May 06, 2022
Dlang Bot
Dec 17, 2022
Iain Buclaw
May 06, 2021
https://issues.dlang.org/show_bug.cgi?id=19587

Dennis <dkorpel@live.nl> changed:

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

--- Comment #1 from Dennis <dkorpel@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.

--
May 06, 2022
https://issues.dlang.org/show_bug.cgi?id=19587

Remi Thebault <remi.thebault@outlook.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |remi.thebault@outlook.com

--- Comment #2 from Remi Thebault <remi.thebault@outlook.com> ---
*** Issue 23094 has been marked as a duplicate of this issue. ***

--
May 06, 2022
https://issues.dlang.org/show_bug.cgi?id=19587

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@rtbo created dlang/phobos pull request #8453 "fix issue 19587" fixing this issue:

- fix issue 19587

  avoid that std.range.generate calls
  fun one time too many

https://github.com/dlang/phobos/pull/8453

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19587

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--