|
Prev: Special container
Next: map within map
From: Patrick May on 7 Sep 2005 10:01 "Earl Purple" <earlpurple(a)gmail.com> writes: > Unlikely to catch you out, but add another if and an else block and > you might get caught out by this: > > if ( cond1 ) > if ( cond2 ) > foo(); > else > bar(); > > which "if" is matching the "else"? The second one. Emacs automatically indents this correctly. > And of course you never use macros, but there are those that do and > > if ( cond1 ) > foo(); > > if foo() is a multi-statement macro, what does it expand to? What if > foo() is a no-op macro here? A) Don't use macros. B) If you do use macros, write them correctly. Regards, Patrick ------------------------------------------------------------------------ S P Engineering, Inc. | The experts in large scale distributed OO | systems design and implementation. pjm(a)spe.com | (C++, Java, Common Lisp, Jini, CORBA, UML) [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: scott urban on 1 Oct 2005 12:01
On 2005-08-14, kevin.hall(a)motioneng.com <kevin.hall(a)motioneng.com> wrote: > The comparisons are not extraneous. The comparisons will take place > either explicitly by the programmer or implicitly by the compiler. > > Having the programmer explicitly specify them just removes a level of > doubt about what the compiler may do. That is why many people prefer > to see the comparisons explicitly listed in the code. I'd like to meet a serious C++ programmer who has any doubt about what the compiler may do for that conditional. If you work with people for whom this is an issue, I feel sorry for you. [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |