why $ is need to access array [negative index]?

Steven Schveighoffer schveiguy at gmail.com
Fri Sep 18 21:04:25 UTC 2020


On 9/18/20 4:46 PM, mw wrote:
> 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.

-boundscheck=off

This currently disables the bounds checks. If your proposed feature went 
in, then it would still have to check the index for sign.

-Steve


More information about the Digitalmars-d mailing list