DIP61: Add namespaces to D
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon Apr 28 07:13:50 PDT 2014
On Mon, 28 Apr 2014 09:24:59 -0400, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Sat, 26 Apr 2014 05:31:51 -0400, Walter Bright
> <newshound2 at digitalmars.com> wrote:
>
>> http://wiki.dlang.org/DIP61
>>
>> Best practices in C++ code increasingly means putting functions and
>> declarations in namespaces. Currently, there is no support in D to call
>> C++ functions in namespaces. The primary issue is that the name
>> mangling doesn't match. Need a simple and straightforward method of
>> indicating namespaces.
>>
>> There have been many proposals earlier:
>>
>> http://forum.dlang.org/post/lhi1lt$269h$1@digitalmars.com
>>
>> but it seems to me that the simplest, most straightforward approach
>> would be better.
>>
>> As more and more people are attempting to call C++ libraries from D,
>> this is getting to be a more and more important issue.
>
> Just reviewed the DIP, I've been following the discussion.
>
> One possible issue, to which I think I know the answer but it should be
> explicit, is conflicting top-level functions and namespace functions:
>
> extern(C++, N) { void foo();}
> extern(C++) void foo();
>
> Clearly, calling N.foo would be unambiguous, but there is no namespace
> to qualify the global foo. I'm assuming .foo() would work, but this
> should be explicit in the DIP. Right now it says use the namespace to
> qualify ambiguous calls.
>
> I think the proposal looks good to me.
I have to rescind this endorsement. I think there is an issue with name
lookup. I will explain in a reply to the other thread.
-Steve
More information about the Digitalmars-d
mailing list