-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
DIP22 - private symbol (in)visibility #5472
Conversation
|
|
Slightly off-topic, but does this DIP address internal linkage at all? IIRC the spec makes statements about private symbols having the same linkage as static in C, but this is not true. |
|
Linkage is completely off-topic, and no dmd always emits fully visible symbols, which isn't a problem due to D's mangling. We want to switch to visibility=hidden for non-exported symbols which allows further LTOs. |
- to clarify the function of this flag
|
This seems to share a lot of the commits for #5485 which makes it even more worthwhile to have each commit be a separate PR. |
#5485 (comment) is based on this PR, so github also shows the commits of this PR in the other PR. |
It's already hard enough to get anything reviewed. Why should I split off a trivial constant renaming to a separate PR, paying all the transaction costs again, and creating additional dependency issues for downstream maintainers or releases. |
- replace access checks by symbol invisibility - no longer find private/package protected symbols - resolves private vs. public symbol collisions in imported modules - resolve mixed private/public overloads
- what symbols are visible depends on each module in an import chain so that anyone importing a module w/ a public import cannot see more than the module itself
|
Github isn't the best tool for reviews (e.g. it show commits in the wrong order). |
As I explained to Kenji:
Please put the non-core ones as separate PRs. |
|
Let's please stop wasting time and get to the matter. This PR isn't trivial and it can't be, but it's already simpler than your lookup change and doesn't contain any unrelated changes. |
Well, that's partly b/c github notifications are mostly gone once you click on them, so confronted with complex PRs and a lack of time, people use small comments as a TODO reminder. And if someone can't grasp a PR right away she should get into contact with the author, e.g. by leaving questions or by scheduling a Skype or IRC meeting if lots of discussion is necessary. |
|
This PR changes +118/-23 lines of non-test code. All it does is adding a new |
|
The way I see it is, the project lead is asking for some reasonable changes. Sure, packaging PRs is not an exact science, everybody has their quirks etc, so each and every thing asked can be debated. But at the top level: the project lead is asking for some reasonable changes. @MartinNowak, do you think there are ways to implement them so he can review and pull this PR? |
If you're referring to #5472 (comment), this was a misunderstanding, #5485 is completely based on the PR, so of course both share the same commits. There isn't anything in this PR that isn't part of the DIP22 change. |
| * checked by the compiler remain usable. Once the deprecation is over, | ||
| * this should be moved to search_correct instead. | ||
| */ | ||
| s = searchScopes(flags | SearchLocalsOnly | IgnoreSymbolVisibility); |
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.
Put check for IgnorErrors and useDeprecated==1 here to avoid unnecessary extra symbol lookups.
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.
This code may also need to be in expression.searchUFCS().
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.
Put check for IgnorErrors and useDeprecated==1 here to avoid unnecessary extra symbol lookups.
I'd still have to return the correct symbol, even if not reporting the deprecation warning.
I can try to gather some stats how often symbol lookup falls through to this old behavior.
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.
This code may also need to be in expression.searchUFCS().
Seems so, will add that and a test case this evening.
|
I'll run some benchmarks, but I don't think this affects anything b/c failed lookups are usually an error and in any case rare. |
- for better error messages and to still allow any usage that might slip access check after overload resolution - the better error message should be produced by search_correct once the deprecation is over
- also do a deprecated search for private symbols in the new part of checkimports - keep old behavior (ignoring symbol visibility) w/ -transition=import and the old part of -transition=checkimports
|
I added 3 commits as you can see above.
|
|
Slowdown is very small 0.1-0.2% for phobos measured without object creation ( |
Not sure what that means. Slow compile times are an accumulation of those "very small" .1-.2 slowdowns, like barnacles on a ship. |
|
Due to these slowdowns, I propose a shorter deprecation cycle for this. |
A few releases (2-3 / 4-6 month) should be fine, it's quite a mess to maintain these extra flags and lookups.
It mean I skipped the codegen pass by using
Well, 0.1% change in semantic speed shouldn't be an argument against such a big change. Anything left to do? |
|
I know we have other time suckers, like the excessive template instantiations. We need to work on all of them, and try not to make things worse. |
|
Auto-merge toggled on |
Yes, we need to work on all of them, but they are all fixable problems. |
DIP22 - private symbol (in)visibility
|
This pull request introduced a regression: |
The main goal of DIP22 and this implementation is to resolve conflicts between private and public symbols. Adding a private symbol to a module or a class should not interfere w/ any code in another module.
This is achieved by ignoring private/package/protected symbols during lookup, thus turning protection from an access into a visibility check.
writelnsymbol instd.stdioand the private aliasimport std.stdio : writelnin another module).In order to not break code by making those symbols invisible an additional lookup with a deprecation warning is performed if the previous scope searches didn't found any symbol.
packageandpackage(std)protection, but also deprecates invisible symbol for now.