-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
DIP1021: Argument Ownership and Function Calls #10249
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10249" |
| escapeByValue(arg, &eb.er); | ||
| } | ||
|
|
||
| foreach (const i, ref eb; escapeBy[0 .. $ - 1]) |
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.
So this is... O((n^2)/2 * (v+r)) in the normal case (no error) (n == escapeBy.length, v == byValue.length, r == byRef.length). That doesn't sound quite right.
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's bad if there are a lot of parameters, but those cases are awfully rare.
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.
Since there is no usage of this yet, we don't know how impactful it will be. But what we already know is that it doesn't scale at all.
|
Don't think this should be added until the DIP actually defines what this is suppose to do. The current DIP is less than bare bones. |
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's okay to merge this under a preview flag. It hurts no one and gives people a real chance to play with it while evaluating the DIP. Same reasoning would also apply to other PRs for DIPs.
| case Tclass: | ||
| return true; // even if the class fields are not mutable | ||
|
|
||
| case Tstruct: |
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 block is not covered
| refs = (eb.param.storageClass & (STC.out_ | STC.ref_)) != 0; | ||
| eb.isMutable = eb.param.isReferenceToMutable(arg.type); | ||
| } | ||
| else |
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 block is not covered
|
Some lines are not covered, e.g. the interaction with |
Codecov Report
@@ Coverage Diff @@
## master #10249 +/- ##
==========================================
+ Coverage 81.92% 81.93% +<.01%
==========================================
Files 143 143
Lines 74952 75080 +128
==========================================
+ Hits 61408 61519 +111
- Misses 13544 13561 +17
Continue to review full report at Codecov.
|
ed28d71
to
87d14ca
Compare
|
Coverage is much better now. |
src/dmd/globals.d
Outdated
| @@ -145,6 +145,7 @@ extern (C++) struct Param | |||
| bool useInline = false; // inline expand functions | |||
| bool useDIP25; // implement http://wiki.dlang.org/DIP25 | |||
| bool noDIP25; // revert to pre-DIP25 behavior | |||
| bool useDIP1021; // implement http://wiki.dlang.org/DIP1021 | |||
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.
That page does not exist on the wiki.
src/dmd/globals.h
Outdated
| @@ -122,6 +122,7 @@ struct Param | |||
| bool useInline; // inline expand functions | |||
| bool useDIP25; // implement http://wiki.dlang.org/DIP25 | |||
| bool noDIP25; // revert to pre-DIP25 behavior | |||
| bool useDIP1021; // implement http://wiki.dlang.org/DIP1021 | |||
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.
That page does not exist on the wiki.
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 will.
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.
I believe you meant this URL: https://github.com/dlang/DIPs/blob/master/DIPs/DIP1021.md
|
Shall we just give up on review if you are just going to merge right after pushing? I can understand merging something that has been stalled for a while, or that has been approved and rebased without significant change, but you've been working on this for the past few hours, did 7 force pushes, and just added the automerge label without any reviews. May I suggest using the "72 hours" label if you feel the PR has waited long enough? |
|
I did fix one minor oversight in the code (delegates and function pointers were not considered). The rest of the force pushes were working on the test cases to get coverage. As for the rest, it has sat around for a month with no comments. If anyone wanted to make a comment on it, they would have by now. |
src/dmd/cli.d
Outdated
| @@ -713,6 +713,8 @@ dmd -cov -unittest myprog.d | |||
| "implement https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md (Scoped Pointers)"), | |||
| Feature("dip1008", "ehnogc", | |||
| "implement https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md (@nogc Throwable)"), | |||
| Feature("dip1021", "useDIP1021", | |||
| "implement https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1021.md (Mutable function arguments)"), | |||
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 URL also appears to be wrong. I think you mean https://github.com/dlang/DIPs/blob/master/DIPs/DIP1021.md
| void test2() | ||
| { | ||
| int i; | ||
| @trusted int* toPtr(ref int i) { return &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.
Shouldn't @safe int* toPtr(ref int i) return work 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.
Just one minor comment (and the fact that all URL to documentation is broken). Otherwise I guess we can take this out for a spin. Did you check what effect it had on Druntime / Phobos ?
87d14ca
to
c08bf7b
Compare
|
Fixed URLs. |
Initial implementation of
https://github.com/dlang/DIPs/blob/793f83911fdc8c88c6ef34e6a36b5e11e3e574e5/DIPs/DIP1021.md