"In praise of Go" discussion on ycombinator

Rainer Deyke rainerd at eldwood.com
Wed Nov 17 12:29:35 PST 2010


On 11/17/2010 03:26, Daniel Gibson wrote:
> Rainer Deyke schrieb:
>> Let's say I see something like this in C/C++/D:
>>
>> if(blah())
>> {
>>   x++;
>> }
>>
>> This is not my usual style, so I have to stop and think.  
> 
> What about
> if( (blah() || foo()) && (x > 42)
>     && (baz.iDontKnowHowtoNameThisMethod() !is null)
>     && someOtherThing.color = COLORS.Octarine )
> {
>   x++;
> }

At first glance, it looks like two statements to me.  The intended
meaning could have been this:

if ((blah() || foo())
    && (x > 42)
    && (baz.iDontKnowHowtoNameThisMethod() !is null)
    && someOtherThing.color == COLORS.Octarine) {
  ++x;
}

Or this:

if((blah() || foo())
    && (x > 42)
    && (baz.iDontKnowHowtoNameThisMethod() !is null)
    && someOtherThing.color == COLORS.Octarine) {}
{
  ++x;
}

The latter seems extremely unlikely, so it was probably the former.
Still, I have to stop and think about it.  There is also the third
possibility that the intended meaning of the statement is something else
entirely, and the relevant parts have been lost or have not yet been
written.

Language-enforced coding standards are a good thing, because they make
foreign code easier to read.  For this purpose, it doesn't matter if the
chosen style is your usual style or if you subjectively like it.  Even a
bad coding standard is better than no coding standard.


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list