Re: [RFA] Add inclusive range support for Rust

Joel Brobecker
2018-04-25T16:27:46Z

Hi Tom,

> /* In an OP_RANGE expression, either bound could be empty, indicating
> that its value is by default that of the corresponding bound of the
> - array or string. So we have four sorts of subrange. This
> - enumeration type is to identify this. */
> -
> + array or string. Also, the upper end of the range can be exclusive
> + or inclusive. So we have six sorts of subrange. This enumeration
> + type is to identify this. */
> +
> enum range_type
> {
> BOTH_BOUND_DEFAULT, /* "(:)" */
> LOW_BOUND_DEFAULT, /* "(:high)" */
> HIGH_BOUND_DEFAULT, /* "(low:)" */
> - NONE_BOUND_DEFAULT /* "(low:high)" */
> + NONE_BOUND_DEFAULT, /* "(low:high)" */
> + NONE_BOUND_DEFAULT_INCLUSIVE, /* Rust "low..=high" */
> + LOW_BOUND_DEFAULT_INCLUSIVE, /* Rust "..=high" */
> };

Where the bounds exclusive before? The comments and the samples
of code I have been finding seem to indicate that the bounds
were already considered inclusive. But I can see how this is
not all that clear.

Perhaps one way to clarify that is to use language-agnostic mathematical
notations for the ranges? Eg, using square brackets such as "[1:3[" or
perhaps "[1:3)" as I have sometimes seen?

I'll continue with the rest of the patch in the meantime...

--
Joel