extern(C++, ns) is wrong

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Sep 13 23:30:33 UTC 2018


On Thursday, September 13, 2018 4:43:47 PM MDT Manu via Digitalmars-d wrote:
> On Thu, 13 Sep 2018 at 13:01, Jonathan M Davis via Digitalmars-d
>
> <digitalmars-d at puremagic.com> wrote:
> > Walter's concerns seem to center around the idea that we somehow need to
> > model C++ namespaces in D, so that's really what needs to be addressed
> > somehow. The D module system gives us everything we need to lay out
> > symbols so that they don't conflict. The only thing that it can't do is
> > allow you to put conflicting symbols in the same module, making it
> > harder to have a 1-to-1 correspondance between D modules and C++ header
> > files in rare cases,
> But consider the overwhelmingly common case where C++ namespaces span
> across many files.
> You can't distribute extern(C++, ns) across D modules, so D fails to
> model C++ namespaces regardless, and in the vast majority case. The
> minority case you point out above is irrelevant by contrast.
> The current design fails at its primary goal right out of the gate,
> but we wear a pile of super-anger-inducing baggage in its wake.

I'm not disagreeing, but I'm not the person who needs to be convinced.
Either way, a DIP needs to be produced which

1. really clearly explains the semantics (which shouldn't be hard given
their simplicity).

2. does an excellent job of explaining the downsides to the current
approach, why they're such a big problem, why workarounds for those problems
are terrible, and why the proposed approach doesn't have those same
problems.

3. and of course, for thoroughness, it needs to explain the downsides to the
proposed approach and the likely workarounds, but the issue of trying to put
multiple namespaces in a single module when they were in a single header
file is the only downside that I'm aware of.

How easy it's going to be to put something together that convinces Walter, I
don't know, but we clearly need a well-written DIP to stand a chance, and I
have no clue what arguments would convince Walter. I don't know what Andrei
thinks on the subject, but maybe the trick is to write the DIP so well that
Andrei is convinced, and then _he_ convinces Walter. And maybe we'll get
lucky, and after Walter mulls over it enough, he'll come around. I don't
know.

Either way, I don't think that you really need to convince many folks who
have actually dealt with extern(C++, NS). At least out of those folks who
say anything in the forums, it seems that pretty much anyone (other than
Walter) who looks into the issue much pretty quickly comes to the conclusion
that the current approach is terrible. It's Walter who is clearly hard to
convince.

- Jonathan M Davis





More information about the Digitalmars-d mailing list