[Insight-developers] namespace itk

Lorensen, William E (CRD) lorensen at crd.ge.com
Wed Aug 9 16:51:26 EDT 2000


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

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com]
Sent: Wednesday, August 09, 2000 1:39 PM
To: Insight Developers
Subject: [Insight-developers] namespace itk


I have changed the way in which we delimit the "itk" namespace in all
currently checked in sources in Insight/Code/Common.  Please use this
method in all new files:

To begin the namespace, use:

ITK_NAMESPACE_BEGIN

instead of

namespace itk {

To end the namespace, use:

ITK_NAMESPACE_END

instead of

} // namespace itk

These macros are defined in itkMacro.h, so they should be available in all
sources.  They are simply defined as:

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

2.) It is easy to change the name of the namespace, or remove it
completely.

3.) Nothing fancy is needed to prevent emacs from indenting any extra
spaces due to the { and } delimiters.

This approach to namespaces used on a large scale seems to be somewhat
common.  An example is in SGI's implementation of STL
(http://www.sgi.com/Technology/STL).  Here the macros are used for the
"std" namespace, in case a compiler wants to ignore it (like gcc without
-fhonor-std).

If anyone has any arguments against this approach, feel free to post them
here.  It would be really easy to remove all the macros, and replace them
with the old "namespace itk {...} //namespace itk" approach.

-Brad



_______________________________________________
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