Make the existence of high(type) clearer, especially near subranges (#18286)

* Make the existence of high(type) clearer, especially around subranges

* Use a better example and dry up the wording
This commit is contained in:
j-james 2021-06-18 03:10:45 -07:00 • committed by GitHub
commit a250481dcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -989,10 +989,12 @@ Ordinal types have the following characteristics:
- Ordinal types are countable and ordered. This property allows the operation - Ordinal types are countable and ordered. This property allows the operation
of functions such as `inc`, `ord`, and `dec` on ordinal types to of functions such as `inc`, `ord`, and `dec` on ordinal types to
be defined. be defined.
- Ordinal values have the smallest possible value. Trying to count further - Ordinal types have a smallest possible value, accessible with `low(type)`.
down than the smallest value produces a panic or a static error. Trying to count further down than the smallest value produces a panic or
- Ordinal values have the largest possible value. Trying to count further a static error.
than the largest value produces a panic or a static error. - Ordinal types have a largest possible value, accessible with `high(type)`.
Trying to count further up than the largest value produces a panic or
a static error.
Integers, bool, characters, and enumeration types (and subranges of these Integers, bool, characters, and enumeration types (and subranges of these
types) belong to ordinal types. types) belong to ordinal types.
@ -1095,6 +1097,7 @@ lowest and highest value of the type. For example:
type type
Subrange = range[0..5] Subrange = range[0..5]
PositiveFloat = range[0.0..Inf] PositiveFloat = range[0.0..Inf]
Positive* = range[1..high(int)] # as defined in `system`
`Subrange` is a subrange of an integer which can only hold the values 0 `Subrange` is a subrange of an integer which can only hold the values 0