From -1810103471701102833
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,fddfa855dc41ba0d
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,fddfa855dc41ba0d
X-Google-Attributes: gidf78e5,public
From: ellis@allegra.att.com (Margaret Ellis)
Subject: Re: Namespaces, naming conflicts
Date: 1995/06/14
Message-ID: <1995Jun14.002909.21985@allegra.att.com>#1/1
X-Deja-AN: 104328776
references: <3r79jk$3se@nms.telepost.no> <DA379D.Jr6@online.tmx.com.au>
organization: AT&T Bell Laboratories, Murray Hill, NJ
newsgroups: comp.lang.c++,comp.std.c++

In article <DA379D.Jr6@online.tmx.com.au> tony@online.tmx.com.au (Tony Cook) writes:
>Rune Huseby (Rune.huseby@gpi.telemax.no) wrote:
>
>: I know that namespaces was introduced to avoid naming-conflicts across 
>: libraries, but who defines the namespace names? It is possible that two 
>: vendors simultanously defines equal namespaces for their libraries, like 
>: 'ODBCLib' or similar. I would expect that the vendors would try to keep the 
>: namespace names as short as possible, so programmers don't have to write 
>: something similar to 'Microsofts_ODBC_library::Connect()'
>
>It's possible for a vendor to define a long name such as
>	Microsofts_ODBC_library
>and then define a short alias.
>-- 
>        Tony Cook - tony@online.tmx.com.au
>                    100237.3425@compuserve.com

Let me add to Tony's observation.  Not only *can* library
implementors *can* use a naming convention for namespaces,
they *should* do so - to reduce the possibility of conflict
with other namespaces.  That is, they *should* use names like
	Microsofts_ODBC_library

Note that use of a namespace (even with a lengthy and
awkward name) is preferable to having to apply a naming
convention to every global name with external linkage in
a library.  The library implementors have only one name
per namespace for which they have to use the possibly
lengthy and awkward name.  And, as Tony notes, providing
an alias is an option.

The only disadvantage of using a namespace right now is
that they are not yet implemented in all C++ compilation
systems, so portability of code that uses namespaces
might be limited.  If the unavailability of a compilation
system supporting namespaces is a problem, define and
adhere to a naming convention.


(Among other things, Martin Carroll and I discuss the
use of naming conventions and namespaces in our new book
"Designing and Coding Reusable C++," just out from
Addison-Wesley.)


Margaret A. Ellis



