Signed word lengths and indexes

Adam Ruppe destructionator at gmail.com
Tue Jun 15 07:18:02 PDT 2010


On 6/15/10, Pelle <pelle.mansson at gmail.com> wrote:
> Using the length is meaningless, any uint >= length will work just as
> well. Using the length there is meaningless, since that's really not
> what you compare against.

The nice thing about length is x < arr.length can be read as "oh, stop
upon going out of bounds". Yes, other numbers would do the same thing
here, but they wouldn't read the same way.

It is more about what the code is saying to the human reader than to
the computer.

> Notice why clever tricks are bad? They generate meaningless discussions :)

Haha, yes!


More information about the Digitalmars-d mailing list