On 7/30/18 12:45 PM, Manu wrote:
On Mon, 30 Jul 2018 at 01:45, Walter Bright via Digitalmars-d
<[email protected]> wrote:
On 7/29/2018 8:05 PM, Manu wrote:
ab.d
------
module ab;
extern(C++, "ab") void foo();
cd.d
------
module cd;
extern(C++, "cd") void foo();
Perfect!
extern(C++, ab) void foo();
extern(C++, cd) void foo();
Perfect!
struct S1 { extern(C++, ns) void foo(); } alias foo = S1.ns.foo;
struct S2 { extern(C++, ns) void bar(); } alias bar = S2.ns.bar;
Perfect!
What is this? I don't get what you are doing here.
We have what already exists, that can't go away now, but please just give us
string namespaces as a mangle-only option. Not only will I shut up about it
forever, but we will also be able to specify namespaces that conflict with D
keywords, and also organise our modules just like all other D code ever.
I'm the one that gets stuck with the fallout from bad designs. The solution I
proposed above will work for you as best as I can tell. And it works right now,
you don't have to wait for another version.
Sure it 'works', but it's an annoying point of friction, and it
doesn't need to be that way.
It requires over-specification of the namespace at calls, and it
creates friction for scanning meta.
It offers nothing, and only makes things harder and unintuitive.
Why do you have such a strong opinion about a thing that you don't use?
None of the customers ever suggested it should be like it is.
Just let us mangle our symbols! We'll design our modules how we like;
we're not morons, we want to present API's to users in logical and
sensible ways.
You haven't explained why you can't just move the namespace ns declarations in
one file together.
Are you serious?
https://github.com/dlang/druntime/pull/2259 <- There, I fixed it for
you. I can't wait to get all the container classes in there too!
If you really believe that, and not just trolling me, then click merge.
hehe, you need to put them all into one extern(C++, std), right? Not to
mention having std as an identifier is somewhat problematic in D.
Why would I want to have one gigantic module with everything dumped in
it? No end-user wants that.
We just want to use D as it is. What is so bad about D's module system
that you plainly refuse to let us use it as it was intended?
Just allow a string version. It's going to be okay. Everybody will be
happier. The sky won't fall.
When torrents of people complain, you can send every single one of
them to me, tell me "I told you so", and I'll eat my hat.
While I agree with Manu that extern(C++, ns) would be better as just
mangling, please don't just make the difference that it's a string
literal vs. symbol. That difference is going to be confusing. Not to
mention the abuse from calling CTFE functions. e.g.:
string ns() { return "theNamespace"; }
extern(C++, ns) or extern(C++, ns())?
I'd suggest something like (shudder) extern(mangleC++, ns).
None of this is attractive...
Note that namespaces in D have been doable via templates or classes or
structs for a long time. There is really no need to deal with C++
namespaces in D.
-Steve