News for hackers. Stuff that matters.
Re:Microfeatures I'd like to see in more languages by tester756 on Saturday January 07, 2023 @08:05AM (#34287665)
I disagree about purity. At some point "math purity" "math correctness" may be not desirable.

In this case everything is about intention

In general accessing index out of range (above or below) is not desirable, in almost all cases this is bug.

And now, in my opinion `array[-1]` when `-1` is hardcoded would tell, with full intention that last index is desired.

Basically it would be translated to `arr[arr.Length - 1]`. You don't write code with `array[-1]` because that's clearly wrong (when there's no going back behaviour)

Meanwhile when it is calculated, then it should result in an error.

The rules are pretty simple I'd say - if you desire to use "reverse syntax" then you can, but when you use variables with may be calculated wrongly, then you will receive an error.

There are no comments on this comment yet.