"Tim Peters" <tim.one at comcast.net> writes: > [Zack Weinberg] >>>> It does, however, lead to a different problem: >>>> >>>> if (condition) >>>> Py_DECREF (foo); >>>> else // oops, syntax error here > > [Martin v. Löwis] >>> How so? This expands to >>> >>> if(condition) >>> if(cond2)action1; >>> else action2; >>> else > > [Zack] >> No, it expands to >> >> if(condition) >> if(cond2) action1; >> else action2;; >> else >> >> -- note the extra semicolon, which provokes a syntax error. > > Zack, which version of Python are you using? The current definition of > Py_DECREF doesn't end with a semicolon: I thought you might come back at me with that. Yes, you can avoid the syntax error by carefully leaving off the semicolon here. I don't consider this to be good style, though. It's easy to forget, and it's easy for someone to come along later and be confused and check in an 'obvious' patch that adds a semicolon - and it might not even break anything... then. I'm really not speaking about the python source code in specific. I'm speaking about general style principles, and I really do think it is good style *always* to wrap complex macros in do { } while (0) whether or not they need it. zw
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4