David Gileadi:
But this requires the following knowledge:
1. That the signed function exists, and its location. As a
casual D programmer I didn't know about it.
2. That there's a need for it at all, which requires knowing
that length is unsigned. I did know this, but I bet in the heat
of programming I'd easily forget it. In a semi-complex
algorithm the bug could easily hide for a long time before
biting.
A solution for similar language design traps/mistakes is static
analysis, with tools like Dscanner trained to recognize the
troubling coding patterns, that should suggest workarounds (or to
use better designed languages. But no language is perfect).
Bye,
bearophile