|
Boost : |
From: Ed Brey (brey_at_[hidden])
Date: 2000-12-06 12:34:19
From: "Beman Dawes" <beman_at_[hidden]>
> At 02:58 PM 12/4/2000 -0800, Gary Powell wrote:
> >> Ed Brey wrote:
> >> > [Paraphrase quote below:]
> >> > namespace boost {
> >> > typedef char int8_t; // ...
> >> > namespace integer {using boost::int8_t; /*...*/}
> >> > }
> >
> >Ok, I'd rather break user code and move these types into a nested
> >namespace.
>
> Wait a minute! For the cast library, we just got finished moving
the names
> out of a nested namespace because of (1) added complexity with
little
> apparent benefit, and (2) some compilers still having nested
namespace
> problems.
>
> The lumpers and the splitters have to get together on this and come
up with
> a boost policy that we can apply evenly to all libraries.
There are multiple, separate suggestions in the works here at once:
On suggestion is to allow the following to work:
boost::uint8_t foo1;
boost::integer::uint8_t foo1;
using namespace boost::integer;
uint8_t foo2;
This combines traditional boost namespace policy with a limited-size
namespace so that the using directive could be used practically
without worry of name clashes. This is capability that the cast
library had. The way this capability was implemented caused problems,
as Beman mentioned. The problems were "solved" by removing this
capability; however, it appears that the problems could also have been
solved by using a different implementation strategy: Declare the names
in namespace boost, as though there were no nested namespace at all,
and then use using declarations to pull the names into a nested
namespace.
The other suggestion is from my interpretation of Gary's comment
above. It is that all the above usage would work except:
boost::uint8_t foo1;
This would be implemented simply with a nested namespace.
Here are pros (some mutually exclusive and/or debatable) I see to each
suggestion:
Dual namespace access:
+ Minimal code needed to access without preceding declarations or
directives.
+ Facilitates keeping track of the library where the item came from
with minimal code: boost::whatever. This is important when
considering that the "boost" name may someday be replaced by "std".
With std::integer::int8_t, you have to choose between the long name,
or a name that doesn't have std (integer::int8_t or int8_t).
+ Facilitates unqualified access to all related names via a single
declaration.
Nested namespace only:
+ Interface is minimal and complete: There aren't two ways to get at
the same thing. Simplicity is maximized.
+ Easy to implement library.
+ Encourages using a more closely scoped qualifier, e.g. "using
boost::integer; integer::int8_t foo;" This pro assumes that qualifying
with the library name, listed as a pro above, is really a con, because
a library name covers too much ground to provide meaning to the code.
+ Facilitates unqualified access to all related names via a single
declaration.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk