gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

The meaning of fractional ranges #108

Closed apblack closed 8 years ago

apblack commented 8 years ago

Right now the collection libraries (in minigrace) insist that both the lower and upper bounds of ranges be integers, and raise exceptions otherwise. This behaviour is documented.

Other alternatives are possible, as @KimBruce mentioned in gracelang/minigrace#168. For example, range.from 1.5 to 5.5 could be sequence [1.5, 2.5, 3.5, 4.5, 5.5]. Or we could round non-integers. Or we could floor non-integers. Or we could ceiling non-integers. Or we could ceiling the lower bound and floor the upper bound, or vice versa. Indeed, the variations are almost endless, which is probably why I chose to raise an exception.

Should we change the current behaviour? If so, to what?

KimBruce commented 8 years ago

Raising the exception is fine. It just changed the behavior from earlier versions. ... and yes, the error message is now very descriptive.

KimBruce commented 8 years ago

The current implementation is fine.