Possible improvement of phobos map?
Paul Backus
snarwin at gmail.com
Wed Jul 6 17:52:59 UTC 2022
On Wednesday, 6 July 2022 at 17:21:29 UTC, H. S. Teoh wrote:
> On Wed, Jul 06, 2022 at 09:00:59AM +0000, JG via Digitalmars-d
> wrote:
>> On Wednesday, 6 July 2022 at 01:28:32 UTC, H. S. Teoh wrote:
>>
>> > In fact, I wonder if the current map couldn't be extended to
>> > handle this.
>>
>> Yes, it definitely could (my second version does this). I
>> guess one
>> downside is that several other range algorithms could do with
>> the same
>> change (rather than using bind which requires no change).
>
> IMO it's worth it. Or maybe use bind internally in Phobos so
> that we don't have to repeat the implementation across
> different Phobos functions. But the user-facing API should be
> as smooth as possible.
Disagree. This would be a textbook example of generality creep
[1]. map currently (sensibly) requires that the function given to
it accept a range element as an argument. Having it go out of its
way to try and accept any function that can be cajoled into
accepting a range element, if you apply some kind of
transformation first (like adding .tupleof), would ultimately
make its behavior more complicated and harder to understand.
[1] https://forum.dlang.org/thread/q6plhj$1l9$1@digitalmars.com
More information about the Digitalmars-d
mailing list