https://d.puremagic.com/issues/show_bug.cgi?id=12169



--- Comment #4 from [email protected] 2014-02-15 06:38:04 PST ---
(In reply to comment #2)

> If sum returned int for ranges of int, it would be 100% identical to
> std.algorithm.reduce.

If it's equal to what reduce does, it gives less surprises to the programmer. I
am sure in Haskell you don't see a sum to act differently from reduce. One is
defined on the other, for uniformity, simplicity and minimize surprises.

Also what do you want sum(long[]) to return on default? A "cent" perhaps?


> It's worth returning a 64-bit quantity because (a) 64-bit
> summing is about as fast as 32-bit summing, (b) the result can be cast to int
> if needed.

I am not so fond of casts. What if later I change the code and I am now summing
floats instead? The cast(int) will remove the floating point part :-)


> I propose we close this.

Let's hear what others think first :-)

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

Reply via email to