April 26, 2014
On 4/26/14, 4:32 PM, Walter Bright wrote:
> Since the namespace keyword doesn't seem to be gaining much traction, an
> alternative syntax would be:
>
>      extern (C++, N.M) { void foo(); }
>
> which would be semantically equivalent to the previous:
>
>      extern (C++) namespace N { namespace M { void foo(); }}

Noice. Would the user call it with N.M.foo() or just foo()? -- Andrei
April 27, 2014
On 04/27/2014 01:59 AM, Andrei Alexandrescu wrote:
> On 4/26/14, 4:32 PM, Walter Bright wrote:
>> Since the namespace keyword doesn't seem to be gaining much traction, an
>> alternative syntax would be:
>>
>>      extern (C++, N.M) { void foo(); }
>>
>> which would be semantically equivalent to the previous:
>>
>>      extern (C++) namespace N { namespace M { void foo(); }}
>
> Noice. Would the user call it with N.M.foo() or just foo()? -- Andrei

foo(), N.foo() or N.M.foo(). (Name clashes may increase the required granularity.)
April 27, 2014
On Sat, Apr 26, 2014 at 04:32:29PM -0700, Walter Bright via Digitalmars-d wrote:
> Since the namespace keyword doesn't seem to be gaining much traction, an alternative syntax would be:
> 
>     extern (C++, N.M) { void foo(); }
> 
> which would be semantically equivalent to the previous:
> 
>     extern (C++) namespace N { namespace M { void foo(); }}

Much better! This clearly ties it to C++ compatibility, so there's no chance of unintentional misuse in native D code. And it doesn't waste a D keyword on C++ compatibility.


T

-- 
If I were two-faced, would I be wearing this one? -- Abraham Lincoln
April 27, 2014
On 4/26/2014 4:59 PM, Andrei Alexandrescu wrote:
> On 4/26/14, 4:32 PM, Walter Bright wrote:
>> Since the namespace keyword doesn't seem to be gaining much traction, an
>> alternative syntax would be:
>>
>>      extern (C++, N.M) { void foo(); }
>>
>> which would be semantically equivalent to the previous:
>>
>>      extern (C++) namespace N { namespace M { void foo(); }}
>
> Noice. Would the user call it with N.M.foo() or just foo()? -- Andrei

Either. The former if there is more than one foo() found by name lookup. Just like for imports.
April 27, 2014
On 4/26/2014 4:35 PM, Dicebot wrote:
> Much better. And global C++ namespace will be plain extern(C++), right?

Right.
April 27, 2014
On Saturday, 26 April 2014 at 23:32:42 UTC, Walter Bright wrote:
> Since the namespace keyword doesn't seem to be gaining much traction, an alternative syntax would be:
>
>     extern (C++, N.M) { void foo(); }
>
> which would be semantically equivalent to the previous:
>
>     extern (C++) namespace N { namespace M { void foo(); }}

Or maybe reuse existing keywords:

    extern (C++) scope N.M { void foo(); }

or

    extern (C++) module interface N.M { void foo(); }


or something along those lines.. but maybe it should look a bit ugly :)
April 27, 2014
"Walter Bright"  wrote in message news:ljh472$2233$1@digitalmars.com...

> True. But what D doesn't have is a global namespace. I don't propose one for D, but C++ symbols may appear in the C++ global namespace, or in a C++
> namespace. So using D modules to represent C++ namespaces has a problem.

I think you've misunderstood me.

Modules should be used for the same exact thing they currently are - organising symbols.

If you want function 'foo' to be inside module 'bar' you put 'foo' inside 'bar'.

Once you have the symbol layout you want, you then annotate the declarations to specify which C++ namespace they are inside, so the mangling matches.

I am NOT suggesting module name and namespace mangling should be tied together.  Use D modules for symbol organisation, and add a simple feature for specifying a C++ namespace when required. 

April 27, 2014
On 4/26/2014 11:22 PM, Daniel Murphy wrote:
> I am NOT suggesting module name and namespace mangling should be tied together.
> Use D modules for symbol organisation, and add a simple feature for specifying a
> C++ namespace when required.

The 'namespace' feature actually does work analogously to modules.
April 27, 2014
"Walter Bright"  wrote in message news:ljiadl$4uq$1@digitalmars.com...

> The 'namespace' feature actually does work analogously to modules.

And it shouldn't.  We have modules that work like modules.  We don't need another. 

April 27, 2014
On 4/27/2014 12:19 AM, Daniel Murphy wrote:
> "Walter Bright"  wrote in message news:ljiadl$4uq$1@digitalmars.com...
>
>> The 'namespace' feature actually does work analogously to modules.
>
> And it shouldn't.  We have modules that work like modules.  We don't need another.

I am not seeing an actual proposal. If I missed it, please point me at it.