Robert Osfield wrote:
> Hi Sukender,
> Code readability is key to spotting algorithm
> errors, so any slip in readability is something to take very seriously
> which is why the !=0 is not what I would deem a good programming
> practice.
>
But I find that the '!= 0' produces far more readable code, when the convention
is consistently adhered to.
It is completely unambigous what is meant by a "if ( (a=b) != 0 )" statement;
the intention was obviously to conditionally check the results of an
assignment. Without the explicit conditional, it may become ambiguous as to
whether the intention was to check on the assignment, or if it was a typo and
supposed to be just a conditional.
And if you would find a statement "if ( (a==b) != 0 )", then you could catch
the comparison instead of assignment; likewise, if ( a=b ) was found, it would
indicate assignment instead of comparison. This holds, of course, only if
consistency is mainted and the "standard" of using "!=" after the assignment is
adhered to.
As I said earlier, I prefer this way (explicit comparison) anyway - the fact
that it saves me the warning is an added benefit beyond the readability issue.
Of course, what is - IMO - the _absolutely_ most readable is to split the
statement in two - i.e., "a = b; if ( a ) {}"
------------------------
Matthew W Fuesz
Software Engineer Asc
Lockheed Martin STS
------------------
Read this topic online here:
http://osgforum.tevs.eu/viewtopic.php?p=4303#4303
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org