[Insight-developers] namespace itk

Miller, James V (CRD) millerjv at crd.ge.com
Thu Aug 10 10:23:03 EDT 2000


I like the second set of macros better than the first.  However, I would prefer not use the macro at
all....

If we macro the namespace, then we'll probably end up macro-ing the "try/catch" block, etc., etc.

-----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