Loose end: ints(), longs()
joe.bowbeer at gmail.com
Tue May 28 10:22:47 PDT 2013
Another reason I'm not keen on ints() and longs() is that they have limited
range despite their cool names. I'd like them more, and they would still
be useful for demos, if they generated Big numbers. In other words,
"range()" makes it clear to me that its range is limited, but "ints()" does
This isn't to say that I'm opposed to ints() but I'm definitely not keen on
Here are a couple other ideas for the renamings you propose:
1. toIntStream(), toLongStream(), etc.
2, Leave "boxed()" as is. There's no reason to rename this, right?
On Tue, May 28, 2013 at 9:47 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 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.
> Actually intRange was already shortened to range() when it got moved from
> Streams to IntStream:
> IntStream r = IntStream.range(1, 10)
> The name itself is plenty short; it is the arguments that seem verbose and
> unnecessarily specific:
> IntStream.rangeClosed(0, Integer.MAX_VALUE)
> seems more "leaky" than
> But are you saying you're fine with the verbose form? Or simply you'd
> rather have a name that sounds more like "range"?
>> On May 28, 2013 9:27 AM, "Brian Goetz" <brian.goetz at oracle.com
>> <mailto: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:
>> 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
>> 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.
More information about the lambda-libs-spec-observers