Re: IntStream.sum (original) (raw)
Remi Forax forax at univ-mlv.fr
Wed Jan 16 07:53:58 PST 2013
- Previous message: IntStream.sum
- Next message: IntStream.sum
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
My argument is when you reduce over integers, you want an integer as result, like int + int is an int.
Reducing over integers and get a long should not be the default behavior because it's not what people espect.
If someone want a long, using reduce is better because reduce require to pass an operator so user can choose the exact semantics he want, throwing an exception or using a BigInteger is perhaps better.
Rémi
Sent from my Phone
----- Reply message ----- From: "Paul Sandoz" <paul.sandoz at oracle.com> To: Cc: <lambda-libs-spec-experts at openjdk.java.net> Subject: IntStream.sum Date: Wed, Jan 16, 2013 14:53
On Jan 16, 2013, at 2:33 PM, Remi Forax <forax at univ-mlv.fr> wrote:
On 01/16/2013 02:32 PM, Paul Sandoz wrote:
On Jan 16, 2013, at 2:15 PM, Remi Forax <forax at univ-mlv.fr> wrote:
And long can hold the result of MAXINT additions?
stream are sized is store in a long if a size if definite or can be infinite so it solves nothing. I don't quite understand the above sentence. Are you suggesting reducing/folding on a infinite stream? yes, and you throw an exception when you've done, Brian talk about that.
Well don't reduce/fold on a infinite stream :-)
I don't really buy into your argument that because there might be streams of size > Integer.MAX_VALUE that it implies sum() solves nothing, seems a rather extreme position to take. Do you think sum() solves nothing regardless of whether it returns an int or long?
Paul.
- Previous message: IntStream.sum
- Next message: IntStream.sum
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list