digitalmars.D.learn - Can't chain reduce(seed, range)
- Yuxuan Shui (3/3) Aug 30 2015 Why is reduce defined as 'auto reduce(S, R)(S seed, R r)',
- Jonathan M Davis via Digitalmars-d-learn (7/10) Aug 30 2015 The reasons why the seed is first are historical. It predates UFCS being
- rsw0x (4/7) Aug 31 2015 You might be interested in this PR
Why is reduce defined as 'auto reduce(S, R)(S seed, R r)', instead of reduce(R r, S seed)? I can't chain it. Maybe provide both?
Aug 30 2015
On Monday, August 31, 2015 01:31:58 Yuxuan Shui via Digitalmars-d-learn wrote:Why is reduce defined as 'auto reduce(S, R)(S seed, R r)', instead of reduce(R r, S seed)? I can't chain it. Maybe provide both?The reasons why the seed is first are historical. It predates UFCS being added to the language, so there was no reason to put the range first when when it was added to Phobos. I believe that there have been attempts to fix it, but AFAIK, they ran into too many problems to be able to do it without breaking existing code. - Jonathan M Davis
Aug 30 2015
On Monday, 31 August 2015 at 01:32:01 UTC, Yuxuan Shui wrote:Why is reduce defined as 'auto reduce(S, R)(S seed, R r)', instead of reduce(R r, S seed)? I can't chain it. Maybe provide both?You might be interested in this PR https://github.com/D-Programming-Language/phobos/pull/1955 It's a bit old, left a ping to see what's up.
Aug 31 2015