[Insight-developers] namespace itk

Lorensen, William E (CRD) lorensen at crd.ge.com
Thu Aug 10 09:16:18 EDT 2000


In the old days... I remember folks macro-ing { and } for for loops, if's and other blocks.
They felt this made the code more readable.

Sorry, but I still don't buy your argument.

But, whatever the consortium consensus, I'll agree to it,

Bill

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com]
Sent: Thursday, August 10, 2000 8:59 AM
To: Lorensen, William E (CRD)
Cc: Insight Developers
Subject: RE: [Insight-developers] namespace itk


Since reason #1 below was the main benefit of the macro approach, perhaps
this pair of macros would be better:

#define NAMESPACE_BEGIN(x)  namespace x {
#define NAMESPACE_END(x)    }

Then we open and close the namespace with:

NAMESPACE_BEGIN(itk)
//.........
NAMESPACE_END(itk)

Once people start using the toolkit, we can't change the namespace's name,
but any user who wants to can easily remove the namespace by overriding
the macro definitions when building itk.

Also, these macros still provide the readability without compromising the
language as much.  Mainly, it is now obvious that the namespace is called
"itk", and not "ITK" or "Itk" or something else.

Before I make this change, I'd like some feedback.  Anyone have any other
arguments?  I can always just change it back to the non-macro version.

-Brad

> My only concern is the over use of macros. Are we trying to define a new language? Should'n the
code
> look like C++ as much as possible?
> 
> Bill
> 


> #define ITK_NAMESPACE_BEGIN namespace itk {
> #define ITK_NAMESPACE_END   }
> 
> Reasons for using macros instead of the namespace keyword include:
> 
> 1.) Improved readability.  Although "namespace itk {" was clear,
> a comment was required to mark the end of the namespace
> ("}" v. "} // namespace itk"), and it is easy to forget to write the
> comment.
> 


_______________________________________________
Insight-developers mailing list
Insight-developers at public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers




More information about the Insight-developers mailing list