Loose end: ints(), longs()

Joe Bowbeer joe.bowbeer at gmail.com
Tue May 28 09:41:01 PDT 2013


I like the renamings you propose.

I'm not really keen on the ints and longs methods though. I'm already used
to intRange, which seems short enough, and is consistent with the other
names, none of which are very short.
On May 28, 2013 9:27 AM, "Brian Goetz" <brian.goetz at oracle.com> wrote:

> Another loose end is a method to generate "all" ints / longs (which are
> sugar for ranges 0..MAX_VALUE.)  These show up in pedagogical examples all
> the time:
>
>   ints().filter(i -> isPrime(i)).limit(100)
>
> The logical place for them is:
>
>   IntStream.ints()
>   LongStream.longs()
>
> but some have raised concern that this might be confusing because we have
> an instance method on IntStream called "longs()" which widens the elements
> from int to long.  While this isn't fatal, it might be confusing.
>
> Perhaps it would be better to rename these conversion methods:
>
>   IntStream: longs(), doubles(), boxed()
>   LongStream: doubles(), boxed()
>   DoubleStream: boxed()
>
> to asInts(), asLongs(), and asBoxed()?
>
> In retrospect, these seem better names anyway.  And they also eliminate
> the conflict above.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20130528/d18caa31/attachment.html 


More information about the lambda-libs-spec-experts mailing list