Re: [eigen] Namespaces

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Thursday 11 October 2007 11:46:54 Andre Krause wrote:
> Cyrille Berger wrote:
> > On Wednesday 10 October 2007, Benoît Jacob wrote:
> >> we initially used namespaces, but switched to prefixing recently. The
> >> reason is that namespace offer little protection as most users will want
> >> to be "using namespace". For instance look at the EiObject class.
> >> Without prefix, it'd be Object. A much too common name. If we
> >> encapsulate it in a namespace, it becomes Eigen::Object, which is safe,
> >> but... most users would like to "using namespace Eigen" and if some
> >> class is called "Object" then "using namespace" is not an option,
> >> because "Object" is a too polluting name.
> >
> > In that case the compiler would return an error, it's hardly a problem.
> >
> >> Look at what Qt does. Qt classes are not encapsulated in any namespace,
> >> instead they have the Q prefix, like "QObject".
> >
> > Qt was first release at a time when namespaces were not well (if at all)
> > supported by most C++ compiler.
>
> why not make the eigen namespace name shorter?
>
> instead of Eigen::Vector<float,4>, just
>
> ei::Vector<float,4> ...
>
> it just looks better / more modern than EiVector...
> and if it is that short, one is less tempted to use "using namespace".
>
> and finally, it is no problem to use some typedefs.
>
> so i personally would rather like to see the prefix "Ei" removed.. but
> well, i could also easily life with the prefix. its just a bit uglier.

It's really a matter of taste. Some people will prefer EiVector because it's 
shorted. Some other people will prefer Ei::Vector because the :: is more 
evocative. In any case, the namespacing is just a special kind of prefixing. 
So here we're only discussing prefix aesthetics -- we could go on forever.

And I'm not sure with what you mean with "it is no problem to use some 
typedefs", but did you know, C++ doesn't allow cross-namespace typedefs. So

namespace A { class B; }
typedef A::B C;

shouldn't compile.

Cheers,
Benoit

Attachment: signature.asc
Description: This is a digitally signed message part.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/