[ros-dev] Re: [ros-svn] [gdalsnes] 18113:-reorderInsertXscendingOrder macro argument order and update uses

Gunnar Dalsnes hardon at online.no
Wed Sep 28 15:53:51 CEST 2005


Richard Campbell wrote:
> Hate to throw my 2 cents in, but why use macros or goto statements at 
> all?  None of the demonstrated code actually needs a goto statement to 
> work. 

Having common cleanup is _very_ good programming practice, and in lack 
of working/efficient try/finally i mean that using gotos and/or macros 
for this highy outweights the (alleged) bad practice of using gotos 
and/or macros.

> Granted i've not seen the actual offensive code , but all 
> examples here can be written without goto statements or macros.  Why 
> bother using either?

Have a look at any medium to large function in ros and youll pretty fast 
find points of return (in case of error/fail) where it fails to do some 
cleanup. Having a common place for cleanup makes it easier to make this 
right.

Example: kernel32\process\create.c:BasepInitializeEnvironment().
return at line 496 & 574: fail to destroy proces params


> At any rate, i'm inclined to agree that macros are 
> a bad idea.  Hiding a mess behind a preprocessor is considered bad 
> coding practice.

Thats exactly what macros _should_ be used for. Hiding mess. Im sure 
macros, gotos etc. can be abused but imo this is not the case here.

G.


More information about the Ros-dev mailing list