Re: Namespace request
- Posted by Jason Gade <jaygade at yahoo.com> Feb 11, 2006
- 522 views
Al Getz wrote: > > Jason Gade wrote: > > > > Rob, can you change namespacing so that more than one file can be included > > into > > the same namespace? > > > > Here is an example of what I want to do: > > > > include misc.e as rds > > include machine.e as rds > > include dll.e as rds > > > > Currently the interpreter gives an error. > > > > Rationale: I want to use namespaces in a file that is intended to be > > included > > by another so as to avoid conflicts in user programs. But when I know that > > there > > will be no conflicts within the files that I'm including I don't want to > > make > > a new namespace for every single include. This will also help prevent > > namespace > > pollution by reducing the number of unique namespaces that a program needs > > to > > come up with. > > Hi there, > > > So i guess you're saying you want to include multiple files under the > same namespace so functions can be called in multiple files using > the same prefix...interesting... Yes. That's the way it works in C++, several related includes are part of the same namespace. C++ also has the 'using namespace' keyword. But right now I'm looking through the listserv archives to understand better how namespace rules actually work. I've noticed so far that they don't exactly do what I think they do. So far I've found that using namespaces within a library won't prevent symbol conflicts in user programs, though using them might make them easier to fix. The user program will still have to use a namespace when a conflict arises. By my example, I don't really expect there to be a symbol conflict with RDS libs, but I was trying to be "future proof" and protect the user from having to worry about it. -- "Any programming problem can be solved by adding a level of indirection." --anonymous "Any performance problem can be solved by removing a level of indirection." --M. Haertel j.