[RFA] Add inclusive range support for Rust

Tom Tromey tom@tromey.com
Thu Apr 26 19:51:00 GMT 2018


>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

>> 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"  */
>> };

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

Yes, I think you are right -- they were inclusive for Fortran.
>From value_f90_subarray:

  return value_slice (array, low_bound, high_bound - low_bound + 1);

What was weird then was that Rust treated them as exclusive, because at
the time Rust only had exclusive ranges.

I can change this and rename the new constants *_EXCLUSIVE.

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

I think it's simple to just write out some text explaining the meanings.
Then we won't need to worry whether someone knows the notation.

Tom



More information about the Gdb-patches mailing list