Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
how to let gcc warn me when I use = in conditions
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Kenny McCormack, post: 2418941"] Absolutely, switching the left and right sides of an equality test as it is conventionally written makes the expression less readable [until the pattern becomes familiar]. The more readable the code, the more likely its errors will be overlooked. "Readable" text describes text that fits a familiar pattern, and which the brain can read faster because it can skip many of the words by filling in their most likely form and meaning. In this case an assignment expression can "read" like an equality test, so the mistake can go undetected.[/QUOTE] Very interesting. (Rest of very eloquent defense of your very clearly non-mainstream position - deleted only to save space) Mainstream thought today is that source code should be *readable* by humans and *understandable* by computers. This is so that you can spend less on humans. My $.02: People who maintain the converse of your (Greg's) position should not be programming in C. (*) (*) Read this carefully - this is not a typo. P.S. If you really care about this "problem" (which hasn't been a problem for me since about the 3rd week of my time as a C programmer), just do: #define EQUALS == and use that for equality tests. P.P.S. This discussion is antique anyway, since every (*) C compiler since about 1989 has issued a warning about this (yes, sometimes you do have to find the right compiler option for it) (*) Don't bother writing in with obscure exceptions to this generalization. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
how to let gcc warn me when I use = in conditions
Top