Skip to content
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

Merged
merged 1 commit into from
Sep 15, 2019

Conversation

WalterBright
Copy link
Member

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your 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 locally

If 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])
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@ghost
Copy link

ghost commented Aug 1, 2019

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.

Copy link
Member

@wilzbach wilzbach left a 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:
Copy link
Member

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
Copy link
Member

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

@Geod24
Copy link
Member

Geod24 commented Aug 11, 2019

Some lines are not covered, e.g. the interaction with inout is written but not tested

@codecov
Copy link

codecov bot commented Aug 12, 2019

Codecov Report

Merging #10249 into master will increase coverage by <.01%.
The diff coverage is 86.71%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/dmd/cli.d 0% <ø> (ø) ⬆️
src/dmd/globals.d 27.39% <ø> (ø) ⬆️
src/dmd/func.d 93.54% <ø> (ø) ⬆️
src/dmd/declaration.d 88.58% <100%> (+0.03%) ⬆️
src/dmd/mars.d 78.15% <100%> (+0.03%) ⬆️
src/dmd/expressionsem.d 90.4% <100%> (ø) ⬆️
src/dmd/escape.d 94.52% <85.95%> (-1.49%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 138b01a...2b41b23. Read the comment docs.

@WalterBright
Copy link
Member Author

Coverage is much better now.

@@ -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
Copy link
Contributor

@JinShil JinShil Sep 10, 2019

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.

@@ -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
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Geod24
Copy link
Member

Geod24 commented Sep 10, 2019

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?

@Geod24 Geod24 added Merge:72h no objection -> merge The PR will be merged if there are no objections raised. and removed Merge:auto-merge labels Sep 10, 2019
@WalterBright
Copy link
Member Author

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)"),
Copy link
Contributor

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; }
Copy link
Member

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 ?

Copy link
Member

@Geod24 Geod24 left a 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 ?

@WalterBright
Copy link
Member Author

Fixed URLs.

@dlang-bot dlang-bot merged commit 639c671 into dlang:master Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge:auto-merge Merge:72h no objection -> merge The PR will be merged if there are no objections raised.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants