DIP61: redone to do extern(C++,N) syntax

Byron via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 28 06:55:11 PDT 2014


On Sun, 27 Apr 2014 12:54:51 -0700, Walter Bright wrote:

> http://wiki.dlang.org/DIP61

I really like this.  I think it is clean simple and a better approach then 
adding the namespace keyword.  Plus when people come to D from C++ they 
wont misuse namespace.  

Since D has awesome module aliasing we don't have to worry to much about 
module/namespace conflicts. Though it would be interesting to alias the 
extern directly (if we cant already).  alias lib1 = extern(C++, 
company.lib1) { .... };

My only concern is when libraries have extension libraries that add to the 
main libraries namespace.  ie:

big_library_everyone_loves_to_use.c++

namespace biglib {
  namespace core {
    ...
  }

}


small_helper_lib_a_few_people_use.c++

namespace biglib {
  void helper1() ... // I call 50 functions so you dont have to!


  namespace core() { ... } // I add extra special memory handlers
}

With the current DIP you have to combine the d/di files to merge the 
extern namespaces.  Makes it hard to maintain these as separate 
libraries.  Specially when your library has a lot of extension libs.  
Maybe someone can write a cleaver mixin for this problem.


Also is there any plans on dealing with newing c++ memory?  Having to add 
factories to all of the c++ libs feels a little goofy, but either way this 
DIP gets us a lot closer to C++/D bliss!

 


More information about the Digitalmars-d mailing list