length's type.
Siarhei Siamashka
siarhei.siamashka at gmail.com
Sat Feb 17 14:50:45 UTC 2024
On Wednesday, 14 February 2024 at 00:56:21 UTC, Kevin Bailey
wrote:
> Personally, I don't have a problem with .length being unsigned.
> How do you have a negative length? My problem is that the
> language doesn't correctly compare signed and unsigned.
The length itself is technically the index of a non-existing
element right after the array. And -1 is technically the index of
a non-existing element right before the array. Hence just
mechanically reversing the direction of processing array elements
during refactoring may be potentially dangerous if one is not
careful enough.
More information about the Digitalmars-d-learn
mailing list