why $ is need to access array [negative index]?
Steven Schveighoffer
schveiguy at gmail.com
Fri Sep 18 21:32:22 UTC 2020
On 9/18/20 5:17 PM, mw wrote:
> On Friday, 18 September 2020 at 21:14:19 UTC, mw wrote:
>> On Friday, 18 September 2020 at 21:11:58 UTC, Steven Schveighoffer wrote:
>>> Well, if you don't care about verbosity.
>>>
>>> signs[(sign + $) % $] = ...;
>>
>> I want compiler writes this verbosity, instead of the user :-)
>
> And ... this [(sign + $) % $] is not right, it's defensive programming:
> and will hide real bugs, e.g.
>
> when array index > array.length.
It depends on how you want to define indexing.
Let me write that a different way:
"And ... this processing of negative indexes is not right, it's
defensive programming: and will hide real bugs, e.g.
when array index < 0"
D array indexing is set in stone. Like really hard, billion-year-old stone.
Again, if you want a different indexing scheme, write a type. D makes it
really easy!
-Steve
More information about the Digitalmars-d
mailing list