Notes IV
Matti Niemenmaa
see_signature at for.real.address
Fri Jan 25 13:41:27 PST 2008
Jason House wrote:
> Oskar Linde Wrote:
>> I think it went something like starting with
>>
>> if (a)
>> b();
>> else
>> c();
>>
>> and later mindlessly changing several b(); into if(d) b();
<snip>
> My personal style is to use {} after an if/else/while/etc whenever the stuff
> that follows uses more than one line with normal indentation practices.
>
> For me, I'd never write:
> if (x == 0)
> if (y == 0)
> foo();
>
> But would instead write:
> if (x == 0){
> if (y == 0)
> foo();
> }
>
> Maybe I've just done too much coding/debugging/recoding/sharing of
> code/etc... It just seems safer to me. It also happens to solve the whole
> else issue.
>
> I wonder if something like this would be an acceptable safety feature in D?
> Would anyone complain about the above being an error? Making it a warning
> could be a compromise, but Walter dislikes warnings.
I would write:
if (x == 0)
if (y == 0)
foo();
Which makes the else-association clear.
There are many ways of dealing with this and I don't think it's necessary to
make it a D or DMD feature. A compiler which keeps track of whitespace (which I
doubt (m)any do) could warn about it, I suppose.
--
E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
More information about the Digitalmars-d
mailing list