ints(), longs(), doubles() <was> Re: Ranges
joe.bowbeer at gmail.com
Mon May 6 00:08:40 PDT 2013
I like the approach Tim suggests.
"range" should behave one way (e.g., half-open), but there should also be
some way to generate a closed range -- and the programmer who needs one
will probably need to consult the javadoc every time it is needed.
On Fri, May 3, 2013 at 10:35 AM, Tim Peierls <tim at peierls.net> wrote:
> On Fri, May 3, 2013 at 1:26 PM, Brian Goetz <brian.goetz at oracle.com>wrote:
>> I don't think it would. While "indexes" does capture the essence of a
>>> common use of this method, I think of [start, bound) as a range, and
>>> would look it up under that name. range and rangeClosed are very similar
>>> concepts; they should have similar names. The potential for confusion
>>> doesn't seem that significant to me.
>> With two forms, I agree. But the next two questions are:
>> - what about decreasing ranges?
>> - what about decreasing closed/half-open ranges (whichever the above
>> Now, if the answer to these incremental questions is "you lose", then
>> range and rangeClosed are fine, and we're done.
> All of these variations seem like things that aren't hard to roll for
> yourself, especially with a few good examples in the javadoc.
> But if range and rangeClosed really don't feel like enough to you, then
> retain the stepped versions (with a different, uglier name) but add an
> open/closed argument so it's only one extra method for each of the
> primitive types and not two.
> rangeFarAfield(start, bound, step, HALF_OPEN);
> Ugly enough that people won't use it unless they have to.
More information about the lambda-libs-spec-observers