Specifying C++ symbols in C++ namespaces

Robert Clipsham robert at octarineparrot.com
Thu Apr 3 08:15:59 PDT 2014


On Thursday, 3 April 2014 at 03:48:08 UTC, Walter Bright wrote:
>> Alternatively you can use another module for the other 
>> namespace.
>
> Forcing C++ code that exists in a single file to be split up 
> among multiple D files is inflicting unnecessary punishment on 
> the poor guy trying to justify migrating to D.

A solution could be to allow this:

----
module foo {
     module bar {
         // equivalent to foo/bar.d
     }
}
extern(C++) module bar {
     // Equivalent to namespace bar {} in C++
}
----

Note that Rust does something similar to this to allow multiple 
modules to be defined in a single file (though Rust also doesn't 
have the correspondence between filesystem location and module 
like D does - perhaps this is acceptable with the introduction of 
package.d?)

Robert


More information about the Digitalmars-d mailing list