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


Peter Alexander <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
                   |                            |m
         AssignedTo|[email protected]        |[email protected]


--- Comment #1 from Peter Alexander <[email protected]> 2014-02-15 
05:49:52 PST ---
This is by design in the code, presumably to avoid overflow (which you are
usually so concerned about, what changed?)

I actually agree with you though. I'd expect sum!(int[]) to return int. In
general, I'd expect sum!(T[]) to return typeof(T.init + T.init), and respect
the language integral promotions.

A nice compromise might be to adjust the API:

int[] xs;
int sum1 = sum(xs);
long sum2 = sum!long(xs);

That way, you can specify what type to return. This also solves the problem of
potential overflows with longs (just specify ReturnType = BigInt).

I'll assign this to Andrei for his thoughts.

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

Reply via email to