Hi Matthew and JP, Well it's always a bad idea to write *many* things in a single line in C/C++. I already saw things like "tab[++x] = (y=z++)", which could be dangerous. I even saw a "x = x++", which is an undefined behaviour (does not do the same depending on the type of x, and depending on the compiler). Well, of course, it has nothing to see with the simple "if (a=b)" in our current discussion though.
I got an idea: we should extensively use the "," operator and code with no whitespaces and no carriage returns... :P Don't you know the IOCCC (International Obfuscated C Code Contest)? That's quite fun: http://www.ioccc.org/ Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ Le Thu, 08 Jan 2009 14:36:59 +0100, J.P. Delport <[email protected]> a écrit: > Hi, > > Matthew Fuesz wrote: >> 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 ) {}" >> > > Well stated, I agree with everything you've said and second the split > statement approach. > > jp > > >> ------------------------ >> 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 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

