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

Gunnar Dalsnes hardon at online.no
Wed Sep 28 00:00:06 CEST 2005

Phillip Susi wrote:
> I'd just like to chime in here with my opinion.  About a year ago I had 
> the idea of introducing macros for error handling instead of explicit 
> gotos.  We had some discussion on the matter, and I read several papers 
> on the web, and came to agree that use of macros that change flow 
> control is anathma.  It makes the code completely unreadable and 
> unmaintainable.

In win32k i use macros for flow control in the NtUser syscalls 
(functionally like a try/finally block) where its very important that 
some cleanup (release a lock) is always done:

BOOL NtFunc()

   if (Stuff) RETURN(FALSE);

   DPRINT1("NtFunc returned %i\n", _ret_);

> At first it seemed like a great idea to hide the "nasty" gotos and have 
> to type less while hammering out the code, but in the end, even when you 
> are familliar with the macros, it looks ugly, and for someone who isn't 
> familliar with the macros, it is utterly unreadable.

If we should only invent stuff that ppl _already_ understand we just had 
to stop inventing.

> Recently I was reading over some apache code and they make extensive use 
> of macros for flow control.  I found myself becoming frustrated to no 
> end because I could not figure out what the hell was going on.  They 
> looked like nice, neat function calls, but I could not for the life of 
> me figure out where the code was that was being called.

So if they had been function calls and not macros it would have been 
easier??? Or should we stop using functions also? ;-P

> It wouldn't 
> have looked so deceptively simple if they coded out what was going on 
> explicitly instead of using macros, but it would have been easy to 
> understand, and why should something look deceptively simple when it 
> really isn't?  

If you cant find a macro (simple text search) you probably wouldnt have 
understod the code _without_ the macros either;-P

But off course you have to learn how the macros work to understand and 
utilize them, but that goes for any code. I cant see how learning a 
function call with 10+ params (typical nt syscall func) should be any 
easier than learning a simple macro. Thats just being lazy.


More information about the Ros-dev mailing list