On Monday, 1 January 2018 at 02:18:36 UTC, Jonathan M Davis wrote:
Except that the reason for arrays throwing RangeErrors when you
try and index them out-of-bounds is to avoid memory safety
issues, which is not necessarily the case at all when you're
talking about ranges. Having ranges in general be checking
empty in front, popFront, back, etc. would add unnecessary
overhead - especially when you consider that ranges often wrap
other ranges. You'd be layering on check after check when the
calling code is already supposed to be checking empty when
necessary to make sure that the range isn't empty. You'd even
be layering checks on top of the checks that arrays already do,
since many ranges are ultimately wrapped around a dynamic array
at their core.
[...]
Makes sense. Especially after pointing out that ranges are mostly
arrays at the end. Thanks!