Feature request: A namespace for Box2D

General Box2D issues or C++ specific issues
model76
Posts: 6
Joined: Sun Dec 07, 2008 5:34 pm

Feature request: A namespace for Box2D

Postby model76 » Sun Dec 07, 2008 5:44 pm

Hi,

I would like to suggest encapsulating Box2D in a namespace, such as "b2".
Along with the advantages of encapsulation, it would also make things easier for people using IDEs with code completion.


Thank you for making this wonderful software!

BorisTheBrave
Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am
Contact:

Re: Feature request: A namespace for Box2D

Postby BorisTheBrave » Mon Dec 08, 2008 8:18 am

Great suggestion, model76. In fact, we've already included this in the trunk. The next release ought to have all m_variables stores in the Box2D.Common.b2internal namespace.

shaktool
Posts: 434
Joined: Sun Jan 20, 2008 7:52 pm
Contact:

Re: Feature request: A namespace for Box2D

Postby shaktool » Mon Dec 08, 2008 11:40 am

The ActionScript version uses namespaces, yes. Were you asking about the C++ version?

BorisTheBrave
Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am
Contact:

Re: Feature request: A namespace for Box2D

Postby BorisTheBrave » Mon Dec 08, 2008 11:55 am

Yes, I'm being presumptive, sorry. I guess I was thinking of the variable name issue, and Box2D has fixed that already in v2.0.1, so that didn't make sense.

model76
Posts: 6
Joined: Sun Dec 07, 2008 5:34 pm

Re: Feature request: A namespace for Box2D

Postby model76 » Mon Dec 08, 2008 2:54 pm

I meant the C++ version, yes. -Sorry for the confusion :)

BorisTheBrave
Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am
Contact:

Re: Feature request: A namespace for Box2D

Postby BorisTheBrave » Mon Dec 08, 2008 4:19 pm

Nono, my fault. I don't really do C++ well enough to answer your (now clarified) question, though.

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: Feature request: A namespace for Box2D

Postby Erin Catto » Wed Dec 10, 2008 11:07 am

I wrote the C++ version to work with poor C++ compilers where namespace support can be spotty. Also, in my experience most game programmers don't use C++ namespaces.

model76
Posts: 6
Joined: Sun Dec 07, 2008 5:34 pm

Re: Feature request: A namespace for Box2D

Postby model76 » Wed Dec 10, 2008 2:00 pm

Erin Catto wrote:Also, in my experience most game programmers don't use C++ namespaces.

Really? Too bad for them! Namespaces ROCK! :D
I certainly wouldn't want to be without them.

Anyway, I see your point about shady compilers, as compatibility rocks even more than namespaces. It would be a shame to leave out exotic platforms, such as mobile phones, drawing pads, refrigerators, and intelligent hairdryers, and what not.

Keep up the good work!

jetforme
Posts: 2
Joined: Thu Dec 25, 2008 5:25 pm

Re: Feature request: A namespace for Box2D

Postby jetforme » Thu Dec 25, 2008 5:29 pm

Erin Catto wrote:I wrote the C++ version to work with poor C++ compilers where namespace support can be spotty. Also, in my experience most game programmers don't use C++ namespaces.


It shouldn't be unreasonable to conditionalize the use of namespaces, although it'd probably make for redundant references (i.e. "b2::b2World").

Internally, there's a "struct Point" that conflicted with Mac OS X headers' Point.

I'd love to see it all in a namespace. Are there really that many compilers in use today for Box2D projects that also don't understand namespaces?

Hangar
Posts: 100
Joined: Fri Dec 14, 2007 9:19 pm

Re: Feature request: A namespace for Box2D

Postby Hangar » Sun Jan 18, 2009 11:54 am

Well, it's relatively easy to wrap it all in a namespace for your own project.

Just make this file:

Code: Select all

namespace box2d {
#include "Box2D.h"
}


Are there really compilers these days that don't do namespaces well? Do people still use them? I think it makes a lot of sense for C++ libraries to live within a namespace.


Return to “Bugs, Requests, and Feedback”



Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest