Skip to content

Comments

remove HiddenParameters, refactor declareThis#10042

Merged
dlang-bot merged 2 commits intodlang:masterfrom
thewilsonator:hidden-params
Mar 11, 2020
Merged

remove HiddenParameters, refactor declareThis#10042
dlang-bot merged 2 commits intodlang:masterfrom
thewilsonator:hidden-params

Conversation

@thewilsonator
Copy link
Contributor

Also qualify the void* __capture context parameter.

@ibuclaw is that used anywhere in GDC? looks like it could be removed from the headers.

@thewilsonator thewilsonator requested a review from ibuclaw as a code owner June 16, 2019 04:48
@dlang-bot
Copy link
Contributor

dlang-bot commented Jun 16, 2019

Thanks for your pull request and interest in making D better, @thewilsonator! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

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 run digger -- build "master + dmd#10042"

@thewilsonator thewilsonator force-pushed the hidden-params branch 3 times, most recently from 8306104 to c0ab4c5 Compare June 16, 2019 06:14
@WalterBright
Copy link
Member

Wasn't this added in the recent fix so two this pointers could be used? Was that all unnecessary, or were insufficient test cases added?

@thewilsonator
Copy link
Contributor Author

Some stuff was added to it with that, but git blame says: #9179

cc @jacob-carlborg

@thewilsonator
Copy link
Contributor Author

For reference this PR is part of me trying to get to the bottom of why closure's contexts are not typed (and type checked) properly.

@jacob-carlborg
Copy link
Contributor

jacob-carlborg commented Jun 16, 2019

declareThis used to return one hidden this parameter. In one of the Objective-C PRs I added a second hidden parameter (because that's required by the Objective-C ABI). I think after that a third parameter was added to handle lambdas that both capture the this pointer and the enclosing function context.

@jacob-carlborg
Copy link
Contributor

I think it's a bit difficult to follow the refactoring in this PR. What is better with this change?

In general I think it's better to have as few methods as possible that modify their parameters or the receiver. The previous version returned the result.

@thewilsonator
Copy link
Contributor Author

The previous version returned the result.

... and then immediately assigned to those members.

What is better with this change?

line count change for one. HiddenParameters exists only as a temporary, there is no reason for it to exist.
This also unifies the way hidden variables are created/analysed reducing indentation and factoring common paths.

@jacob-carlborg
Copy link
Contributor

and then immediately assigned to those members.

Yes. I still think it’s better. I’ve been trying to use DMD as a library now for a while and it’s a pain in the ass that the compiler changes things inline all over the place.

It would be much better if one method was responsible for one thing and didn’t modify values in place.

Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

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

Pretty sure that this can just be internal to the frontend.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 9, 2020

I have no problem with this if you think it's ready for inclusion.

v.storage_class |= STC.parameter | STC.nodtor;
if (type.ty == Tfunction)
Type tthis = addModStc(isThis2 ?
Type.tvoidptr.sarrayOf(2).pointerTo() :
Copy link
Member

Choose a reason for hiding this comment

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

Note to self, this type could be cached somewhere for easy comparison in the backend where void*[2]* can be replaced with a two field struct with the actual context types as its fields.

@dlang-bot dlang-bot merged commit b2d6cd4 into dlang:master Mar 11, 2020
@thewilsonator thewilsonator deleted the hidden-params branch July 1, 2021 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants