Re: [eigen] Namespaces

[ Thread Index | Date Index | More Archives ]

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

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.

Mail converted by MHonArc 2.6.19+