ints(), longs(), doubles() <was> Re: Ranges

Tim Peierls tim at peierls.net
Fri May 3 10:35:31 PDT 2013


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
> isnt)?
>
> 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.

--tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20130503/e5c871c9/attachment.html 


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