DMD 1.019 and 2.003 releases
James Dennett
jdennett at acm.org
Wed Jul 25 20:58:57 PDT 2007
0ffh wrote:
> Derek Parnell wrote:
>> 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.
>
> I think maybe you wanted to address me here, not Robert.
> A second is a looonng time! :)
>
>> 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.
>
> I know the argument well. I use it myself to argue for fully braced
> expressions instead of relying on operator precedence (apart from
> the usual exceptions). Also, braces will actually help me parsing.
>
> BUT there is a huge difference here: I'll repeat it this once before
> stopping to do this (I don't believe in reiteration contests):
>
> Using integers or pointers as bools is
>
> 1. /Easy/ to understand and use correctly
> 2. /Shorter/ - less to type and less to take in - and therefore
> 3. /Faster/ to parse mentally (once you're used to it), also it's
> 4. Not obligatory for those who feel uncomfortable with it, but
> 5. Looks one darn hell better
> than having a detrimental tumour of nop characters attached.
And, with a similar amount of evidence, I claim that being explicit
about comparisons with zero or null is
1. Easier to understand and use correctly;
2. More explicit - less to fill in implicitly, and therefore
3. Faster to parse mentally (once you're used to rigor), also it's
4. Not obligatory for those who feel uncomfortable with it, but
5. Looks one darn hell better than having expressions that are
morally, if not technically, type errors left in code.
I suspect, but cannot prove, that it's also less error-prone.
However, without evidence, the debate is pointless.
-- James
More information about the Digitalmars-d-announce
mailing list