extern(C++, NS)

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 30 12:47:19 PST 2015


On Monday, 30 November 2015 at 19:38:53 UTC, Walter Bright wrote:
> On 11/30/2015 10:51 AM, Ola Fosheim Grøstad wrote:
>> On Monday, 30 November 2015 at 17:38:06 UTC, Walter Bright 
>> wrote:
>>> It'd be worthwhile to learn how D's name lookup system works 
>>> before declaring
>>> it lame and insufficient:
>>
>> Nobody has said anything about lame. The issue is that you 
>> don't need to know of
>> "version1" on the C++ side.
>
> Did you look at the example I posted?

Yes, the problem I see is:

1. You need to know about "version1" which is an internal 
namespace on the C++ side, so you cannot just create binding to 
the documented API, but need to go through the source code just 
to discover that "version1" exists.

2. If the library internals changes on the C++ side it causes 
problems for D application code, but not for C++ application code.

3.  In order to keep the D and the C++ side call the same set of 
APIs (if desired) you also need to know on the D side whether the 
current C++ configuration has enabled "version1" or "version2" (+ 
a bunch of other potential variations).

In essence the C++ model isn't friendly to foreign languages. 
They keep bolting on "neat hacks" to extend the language in 
nonbreaking "transparent" ways (on the C++ side).




More information about the Digitalmars-d mailing list