[Issue 10670] std.algorithm.reduce: no-seed initialization wrong design

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 22 22:59:41 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10670



--- Comment #5 from monarchdodra at gmail.com 2013-07-22 22:59:37 PDT ---
(In reply to comment #4)
> (In reply to comment #2)
> 
> > In the case of floats, well... I'd argue that using the seedless variety of
> > reduce on a float range is already a bug,
> 
> I don't think it's a bug, this is Python:
> 
> >>> a = [2.0, 3.0, 4.0]
> >>> reduce(lambda x, y: x * y, a)
> 24.0
> 
> I have a ton of D code that relies on such behavour of D reduce.

You could be right, and I've seen use cases where it makes a lot of sense, eg:
reduce!`a ~ " " ~ b`(["hello", "world"]);

> I suggest to just swap the seed and sequence arguments of reduce, to support
> UFCS chains, and leave the rest of reduce as it is.

I've tried in http://d.puremagic.com/issues/show_bug.cgi?id=8755, but the
conclusion is that it is not possible without breaking code. And when I say
"breaking code", I mean "still compiles but silently generates different
results". That, and no migration plan was found. Short of finding a new name
for a new function, I have not been able to achieve this goad.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list