extern(C++, ns) is wrong

Neia Neutuladh neia at ikeran.org
Sat Sep 15 01:41:18 UTC 2018


On Saturday, 15 September 2018 at 00:07:44 UTC, Danni Coy wrote:
> So extern(C++,"ns") replaces the existing syntax

It would be in addition, at least at first. The current syntax 
might be deprecated.

> and then improve D's general ability to hand functioning 
> hijacking other functions would be the best solution

D already has tools for this.

> and Walters modelling of namespaces is fixing the problem in 
> the wrong place?

The current solution solves the very uncommon problem of having 
two different namespaces in the same file, containing symbols 
with the same names (or, if functions, with common overloads), 
where the person writing the bindings needs to keep a one-to-one 
correspondence between C++ headers and D files, and they don't 
want to introduce any meaningless structs or templates.

Specifically, Walter wants this to compile:

module whatever;
extern(C++, foo) void doStuff();
extern(C++, bar) void doStuff();

And he's not too concerned that you might have to use doubly 
fully qualified names to refer to C++ symbols, like:

import core.stdcpp.sstream;
import core.stdcpp.vector;
core.stdcpp.vector.std.vector v;


More information about the Digitalmars-d mailing list