Actions

EmSys

CCoding Style - Be Clear2

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Be Clear ...

Some constructs seem to invite abuse. The ?: operator can lead to mysterious code:

child = (!LC&&!RC)?0:(!LC?RC:LC);

It’s almost impossible to figure out what this code does without following all the possible paths through the expression.

if( LC == 0 && RC == 0 )
    child = 0;
else if( LC == 0 )
    child = RC;
else child = LC;