D - Module Priority
- D Man (28/28) Aug 17 2001 In C++, I have always wanted to define a priorty for namespaces. For
In C++, I have always wanted to define a priorty for namespaces. For example: namespace foo { int x; } namespace bar { int x; } // The C++ way... using namespace std; using namespace foo; using namespace bar; foo::x = bar::x; // My way... // namespaces are in priority order... using namespace std, foo, bar; x = bar::x; // foo is implicit because the priority is explicity defined.. So, if you import a module in D, it would be nice to set explicit priorities and assume that the current module has priority over the imported module. Comments on my rambling? _________________________________________________ Robert Sitton Software Engineer & Digital Holographer clockwork austin.rr.com "Some engineers code to live, but I live to code..." www.zebraimaging.com www.apple.com www.nintendo.com
Aug 17 2001
D Man wrote in message <9lkub4$309p$1 digitaldaemon.com>...So, if you import a module in D, it would be nice to set explicitprioritiesand assume that the current module has priority over the imported module. Comments on my rambling?In D, the current module has priority over imported modules. All imported modules have equal priority, which means if there's an ambiguity, you'll need to resolve it by prefixing the reference with "modulename."
Aug 17 2001
Walter wrote:D Man wrote in message <9lkub4$309p$1 digitaldaemon.com>...You currently import all the symbols from a module into the current namespace. Would you be opposed to adding a syntax to select only sertain symbols to be inserted into the local namespace, or to have no symbols (other than the module name itself) inserted? It might even be nice to have the compiler tell you if you are explictly importing symbols that you don't use so you can tell when you've removed the need for a module. The ability to select where you get your symbols will also prevent the situation when you code uses symbols from a module A and and later you and a module B for added features. If names clash, you then have to go find and qualify all offending symbols. I do believe you should also keep the current ability to grab everything since this will be handy for small quick projects. I've just always thought that senseless namespace polutions was generally bad. DanSo, if you import a module in D, it would be nice to set explicitprioritiesand assume that the current module has priority over the imported module. Comments on my rambling?In D, the current module has priority over imported modules. All imported modules have equal priority, which means if there's an ambiguity, you'll need to resolve it by prefixing the reference with "modulename."
Aug 19 2001
"Walter" <walter digitalmars.com> wrote in message news:9lkvr5$317f$1 digitaldaemon.com...D Man wrote in message <9lkub4$309p$1 digitaldaemon.com>...For more insight on this, I suggest taking a look at the "More useful (but complex) imports" thread. There's discussion of the Java import model that potentially takes care of some of these problems. -BradySo, if you import a module in D, it would be nice to set explicitprioritiesand assume that the current module has priority over the imported module. Comments on my rambling?In D, the current module has priority over imported modules. All imported modules have equal priority, which means if there's an ambiguity, you'll need to resolve it by prefixing the reference with "modulename."
Aug 19 2001