And there are methods other then using goto that allow for common
cleanup. One such example is:
int somefunction()
{
BOOL bSuccess;
if ( someotherfunction(arg) )
{
if ( yetanotherfunction(arg) )
{
bSuccess = TRUE;
}
}
CleanUpCode;
}
Anyways, back to the point. Most devs have already argued against the
idea of using macros. I say the discussion stops and we call a vote.
Gunnar Dalsnes wrote:
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.
_______________________________________________
Ros-dev mailing list
Ros-dev(a)reactos.com
http://reactos.com:8080/mailman/listinfo/ros-dev