DMD 1.019 and 2.003 releases
Derek Parnell
derek at psyc.ward
Wed Jul 25 00:53:39 PDT 2007
On Tue, 24 Jul 2007 20:55:41 -0400, Robert Fraser wrote:
> for(int i = 100; i; i--) // Takes a second to mentally figure out what's going on
I'm still not explaining myself I guess. Yes, it doesn't take much to work
out what the compiler is going to generate for that code. But that is not
the issue I'm addressing.
If one see's a line of code like that one has trouble recognising that what
was written may not have been what was intended to be written. How do we
know that the code shouldn't have been ...
for(int i = 100; i>1; i--)
and the coder made a small typo out of (bad?) habits. If however, one gets
used to typing 'i>0' or similar fully specified comparisions, we all have a
better confidence level that the code is written as intended to be written.
Of course, it is not a way to prevent all errors, but just a technique to
reduce coding errors.
And a good compiler can still optimise such constructions without us having
to hold its hand it all the way to the machine-code.
I write program code for humans not for computers. It's the compiler's job
to prepare it for the computer.
Sorry that this sounds so pompous and self-righteous. That is not how I'm
trying to sound.
--
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"
More information about the Digitalmars-d-announce
mailing list