On Oct 4, 3:33 am, (e-mail address removed) wrote:
I have a book called "The Bytes Brothers", is your
email address anything to do with that?
Not really, it is an example of bad indentation being evil. Cf:
if ((type == vhpiCompInstStmtK) || (type == vhpiRootInstK))
if (reason)
*reason = "Object is a scope";
else if (reason)
*reason = "object is not writable";
In fact, even better than both ideas is:
if ( reason )
{
if ( type == vhpiCompInstStmtK || type == vhpiRootInstK )
*reason = "Object is a scope";
else
*reason = "object is not writable";
}
But the braces are only necessary if you heed keith's advice (to whom
you responded), right?
Better yet is:
if ( reason )
{
if ( (type == vhpiCompInstStmtK) || (type == vhpiRootInstK) )
{
/* do something */
}
else
{
/* do something else */
}
}
Consistency is an important aspect of quality software. Whether it's
consistently good or bad is an entirely different matter.
I think you and keith are both right. You are welcome to apply to work
for me anytime :^)
Both unconditional use of braces, as keith purported, and proper
indentation, as you purported, should be specified in a properly
formed coding standard. Both of these rules are primarily intended to
reduce and ideally eliminate the probability that the "maintenance"
person will screw up the software with his or her changes.
In a desktop "Paint" program this may seem like a trivial pursuit, but
in the world of safety critical software, such conventions or
practices or standards go a real, real long way towards achieving high
quality software. You can bet your life on it, if you're so inclined.
And maybe--just maybe--what's good for safety critical software is
also good for the desktop "Paint" program. Based on my experience, I'd
bet my life on that.
Best regards,