why $ is need to access array [negative index]?
mw
mingwu at gmail.com
Fri Sep 18 20:46:00 UTC 2020
On Friday, 18 September 2020 at 20:06:01 UTC, Steven
Schveighoffer wrote:
>
> I would say no. The indexing code lowers to a machine
> instruction. Making it so a negative value means something else
> means every single indexing operation is going to have to check
> whether it's negative, and if so do something completely
> different.
Currently we have range check on every single indexing operation
already; so the trade-off here is: adding one more check v.s. the
convenience it buys.
>
> You can create your own array type if you want this behavior.
More information about the Digitalmars-d
mailing list