DIP61: Add namespaces to D
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 26 13:07:26 PDT 2014
On 4/26/14, 12:27 PM, Daniel Murphy wrote:
> "Walter Bright" wrote in message news:ljgt9v$1psm$1 at digitalmars.com...
>
>> Having a pragma to just add mangling doesn't deal with problems like:
>>
>> namespace N { int foo(); }
>> namespace M { int foo(); }
>>
>> foo(); // how to specify which one gets called?
>>
>> I.e. only addressing name mangling does not scale. Need actual scopes,
>> too.
>
> We already have a feature to manage conflicts and organisation in D code
> - modules! There is no need to add namespaces to do that, and if that's
> really what you want it belongs in a completely different discussion.
>
> The thing we can't (easily) do is mangle C++ namespaces, so a feature
> that only affects mangling is perfect.
>
> i.e. We don't need namespaces in D, because modules cover that. We only
> need namespace mangling.
Yah, that's why something along the lines of
extern(C++) module facebook.folly;
comes to mind. Following such a module declaration, stuff inside of it
is considered inside C++ namespace facebook::folly.
The disadvantage of this is that it forces one .di file per namespace,
whereas in C++ people frequently use different namespaces within the
same file.
Andrei
More information about the Digitalmars-d
mailing list