by beatgammit · 7y ago · 0 comments
while ((status = systemcall(...)) != SUCCESS) {
do something with status;
}
Leave a comment there explaining the assignment.Likewise:
if ((status = systemcall(...)) != SUCCESS) goto error;
Or something like that. I don't understand the hate, just make sure it's obvious what you're doing. int c;
while((c = getopt(argc, argv, argstr)) >= 0) {...}
I’d say it’s acceptable, and Python is adding syntax so it can mix assignments and checks.Please don't. This is a perfectly understandable idiom in C. Don't explain the language in your comments; that's the job of a text book, which should be read by anyone before they read your code.
But enabling it on the language level brings a large amount of risk and complexity just for what amounts to a micro-optimization.