Re: [eigen] Namespaces |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Thanks for the long e-mail, Donald. I received it as I was reverting to namespace Eigen, and so it almost felt good to know that you also were in favor of a namespace :) Anyway, this is committed. I haved added a CCMAIL in the commit message to this list, but apparently the mail hasn't yet been sent. So we currently have everything in a namespace Eigen. And we have a macro, USING_EIGEN_DATA_TYPES, that does 'using' on the Matrix class and its typedefs (these typedefs are not too polluting thanks to their suffixes, like Vector2d). So many users will be able to do USING_EIGEN_DATA_TYPES, and never have to write Eigen::, without polluting the global namespace with names such as "Object". Hope that is satisfying, and thanks Konstantin, Cyrille, Andre, Ben, Donald for contributing your opinions, Benoit On Thursday 11 October 2007 21:35:08 Donald Ephraim Curtis wrote: > Man this is a tough conversation. I do like namespaces, they seem like > a proper way to do it because that's why they were put into the > language, (although i don't know strousup) but both ways accomplish the > same thing, just one is emulating namespaces. If I had to vote I'd say > use the namespace Eigen because I like them. I know we did namespaces > with Avogadro and I still consider that maybe AMainWindow might have > been better, but honestly I don't regret it. > > I have a couple things for you to consider Benoit then i'll be done. I > tried to think this out well and please don't take it as an attack. > > 1) Using a namespace gives the _option_ to the developer to type out the > prefix 'Eigen::' everytime or allow them to do 'using Eigen::Object' or > to use 'using namespace Eigen'. If you name the object EiObject you are > forcing them to type Ei everytime and even with autocomplete. Having to > type Eigen::Object with autocomplete becomes E<tab>::O<tab> whereas > EiObject is EiO<tab> so maybe a little typing saved but negligable. > > 2) The only time you need to worry about the namespace is when declaring > a variable or calling a function in that namespace. For the latter you > don't want to have global functions prefixed with eiDoSomething (in my > opinion). qSort is ackward to me whereas Qt::sort. It could be > cosmetic. > > 3) Namespaces are more proper. Just cause QT doesn't use them doesn't > make it right. Qt does use namespaces for their global defines (enums). > I find it annoying because I'd just as well do a using namespace Qt when > I'm using Qt functions and have it know what enum i'm talking about. I > agree that just because they are proper doesn't make them the best way. > Consider though that namespaces are a part of a lot of formalisms (XML, > Java, Python) and when you look at people wanting to use Eigen for code > generated from UML or some higher level formalism like Model Driven > Architecture you're going to want that namespace. Also i read an > article that when they did bindings for Ruby or something for KDE that > they had to use namespaces and had to work around it. > > 4) There is an argument to be made that even with namespaces that > ambiguity can exist. But that's due to bad programming. Just make sure > you're not doing something to make up for the problem of a bad > programmer. Managing namespaces is a part of being a good programmer. > > Doesn't KDE now use namespaces? I think it does even though it's a > little ugly like KDE:KMainWindow or something like that. > > Anyways, I think it's up to you. If you like EiVector i'm totally cool > with it. You do a termendous job with Eigen and also have contributed > to Avogadro so much I think you should do what you want. If anyone is > goign to _not_ use your library for that reason then their loss. And if > you decide to go Eigen:: and then change your mind i'll help you search > and replace with Ei prefix. > > -- > Donald > > Also read the wiki on namespaces maybe that will help ya decide. > http://en.wikipedia.org/wiki/Namespace_(computer_science) > > (Thu, Oct 11, 2007 at 08:55:30PM +0200) Benoît Jacob <jacob@xxxxxxxxxxxxxxx>: > > Argh. > > > > Seems like aside from me, everybody is either in favor of a namespace, or > > doesn't care. > > > > You, Cyrille, Konstantin, Andre. > > > > I'm generally in favor of dictatorship, but every dictator has to listen > > to the people once in a while. > > > > So maybe, we'll revert to namespace Eigen:: instead of a prefix. > > > > But not tonight. Let's give this whole issue more time to ripen. > > > > Cheers, > > Benoit > > > > On Thursday 11 October 2007 20:48:44 Schleimer, Ben wrote: > > > > > 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. > > > > > > I have to agree with Cyrille. It would be cleaner to use Eigen::Object > > > instead of prefixing every class with Ei. Let the application > > > programmer figure out which "using" statements they want to do. It'll > > > probably be rare to get namespace collisions if eigen is the only > > > matrix library used in an application. Plus, when Eigen3 comes out, > > > it'll be easier for app programmers to which by changing the "using > > > EigenX" instead of the prefix. > > > > > > Cheers > > > Ben
Attachment:
signature.asc
Description: This is a digitally signed message part.
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |