-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DIP61: C++ namespaces #3517
DIP61: C++ namespaces #3517
Conversation
|
Boost stuff should be in another pull request. |
|
I'm also not sure whether you can just change the license without explicitly getting the okay from all other contributors. I'm not an expert for US copyright law, but usually, contributing code to an open source project under a certain license isn't necessarily seen as implying a copyright assignment. |
The files are copyrighted by Digital Mars, hence Digital Mars can change the license. |
|
@WalterBright: I don't think publishing a patch to a file with a copyright notice (e.g. opening a pull request) automatically implies assigning the copyright for the changes to the entity specified there. At least, people seem to doubt that such an opinion would hold up in court. Otherwise, there would be no reason for the various open source projects which require contributors to explicitly assign the copyright to do so. |
|
The assigning copyright thing happens when somebody tries to submit |
|
Anyhow, I changed the license for cppmangle.c back for the moment because this discussion should be about DIP61, not licenses. |
| { | ||
| assert(link != LINKdefault); | ||
| assert(idents->dim); | ||
| for (size_t i = idents->dim; i;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put --i in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be i--, not --i, and that confusion is why.
|
Shouldn't there be tests for the actual mangling and linking with some C++ code? |
Yes, and there are: see the test case cppa.d and cppb.cpp. The mangling is correct if the object files link successfully. No need to compare strings. |
|
@WalterBright: I agree that this should be discussed in a different place. However, my point was just that the fact that a patch does not change the copyright notice in a file might not necessarily be enough to assume that contributors assign their copyright to you. I am not a lawyer, and additionally our copyright system (Western Europe) is quite different from the U.S. one, so my understanding of the issue is likely not to be fully correct. Still, many other open source projects make a much bigger deal out of this. It might just be a case of "better safe than sorry" for these projects, but if you know of a publicly available source supporting your opinion (of course, no legal advice, etc.), I'd be very interested. |
|
@klickverbot let's discuss it in a different place, then. I'll do another PR just for that. And no, I don't have a document link. #3519 |
Now I see it. |
|
Hmm... this'll complicate areas around debug codegen. |
|
How so? Why would it be any different than for |
|
In terms of representing namespaces in debug. It's mostly an implementation restriction on my side. I also see in your examples that |
|
Shouldn't namespaces be emitted to DWARF the same way as C++ namespaces? |
|
Documentation pull: dlang/dlang.org#572 |
| if (members) | ||
| { | ||
| for (size_t i = 0; i < members->dim; i++) | ||
| { Dsymbol *s = (*members)[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be no code after {, sigh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
LGTM. I think the design is adequate. |
|
I have some problems with this, please give me some time to test it before you merge it. |
|
@yebblies any update? |
I don't think this deserves it's own syntax, ast class or new lookup rule. Here is a partial implementation using a pragma that should demonstrate how much simpler it could be. I don't think adding new syntax for interfacing to other language features is a scalable approach, and the presence of namespace scopes in D will result in them being used for purposes other than interfacing with C++. We have a module system for that purpose and we shouldn't be introducing alternative organisation methods as a side effect of a change like this. On the implementation side, will this produce garbage when a namespace is declared inside a class or other aggregate? eg I can't see a check to limit this feature to module scope, but maybe I missed it. |
It's valid and works fine producing a function mangled as: |
I appreciate that you wrote an implementation proof of concept for your idea. The downsides of it are, as I see it:
I also believe we discussed this at length in the n.g. I wish we could have arrived at a consensus, but most people did indicate a preference for the PR's design. |
Yes, the problem is an implementation detail left and right. Left because I don't think GCC anticipated a language to emit both DWARF modules and DWARF namespaces. Right because I never anticipated D supporting namespaces (in the patches I've been prepp'ing and sending to GDB). |
I don't like arguing against a pull request for an alternative feature without having one of my own. An opinion with a patch carries a lot more weight in my view,
I don't think this is a big problem, because it should be very uncommon feature in user code. It is a low-level interfacing feature, and I seriously hope most uses will be in (semi-)automatically generated bindings. My experience is most developers would not be able to easily fix the linker errors caused by using this incorrectly.
This is intentional. eg This code will be valid D, and it WILL be used like this (it will replace the current struct/class workarounds). extern(C++, MyNamespace)
{
extern(D):
...
}I'm sure you can agree that we can come up with better syntax for namespaces if we want to add them as first-class constructs. Since you're effectively adding full namespaces, why should they syntactically be tied to
Functions with the same name/arguments should be placed in different D modules. The module is D's unit of organisation and provides powerful tools for disambiguation. If this is not sufficient, then we should consider adding namespaces to D with a dedicated syntax.
I can hardly argue that you don't suspect something. Can you think of any issues?
As I recall most of the objections to my objections were actually misunderstandings. Hopefully now you have a better understanding of what I'm proposing and why. In summary - this pull adds namespaces to D, and ties them syntactically to
|
I would prefer the first option. |
|
Same here. |
|
This was all hashed out here: |
|
I think this proposal is plenty adequate, and in my opinion it's better than @yebblies' alternative. Both designs "work", so at some point a judgment call has to be made. I'll pull this now. We can unpull later if a good argument comes about. |
|
FYI: Standard special-case substitutions in C++ (for Itanium) The first three are probably all that matter. The others only apply to specific C++ templates. |
|
This is just incase someone thinks they can now do |
|
FYI: Resolved #7961 |
Add informative range errors for arrays Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com> Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Also started changing the license to Boost.
http://wiki.dlang.org/DIP61