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

[cling-cpt] Reducing global variable mutaiton [skip-ci] #10883

Closed
wants to merge 3 commits into from

Conversation

saisoma123
Copy link
Contributor

@saisoma123 saisoma123 commented Jul 1, 2022

This Pull request: Reduces global variable mutation, and is now easier to debug.

Changes or fixes: Created a new Cpt class, moved all functions that use global variables to this class, and then made all the globals instance variables of the Cpt class.

Checklist:

  • [NA] tested changes locally
  • updated the docs (if necessary)

This PR fixes issue mentioned in the meta-issue list #406 (root-project/cling#406).

This change occurred as it was mentioned in the meta issue list,
so all the functions that use a global variable were moved
to the Cpt class, and all the globals are now instance
variables of the Cpt class, except for clangdir and
llvm_flags, as it was unneccesary to change those.
It is now much easier to debug the code, as there is
way less global mutation occuring.
@saisoma123 saisoma123 requested a review from Axel-Naumann as a code owner July 1, 2022 20:47
@phsft-bot
Copy link

Can one of the admins verify this patch?

@Axel-Naumann Axel-Naumann requested review from vgvassilev and removed request for Axel-Naumann July 4, 2022 07:46
@vgvassilev
Copy link
Member

I think this PR is not going in the direction of resolving the underlying issue. The idea in the issue, iiuc, is that we have variables (on the global scope) which were mutated by a lot of functions. Moving these variables to become class variables does not solve the mutation problems.

I think a viable way forward is to teach functions not use global variables but to pass these global variables as parameters. This way we will know which function requires what state. Then we can think how to refactor it further.

@saisoma123
Copy link
Contributor Author

Thank you I'll work on it

@saisoma123
Copy link
Contributor Author

I'll close this pull request and make a new one with the parameter passing style you mentioned @vgvassilev

@saisoma123 saisoma123 closed this Jul 12, 2022
@saisoma123 saisoma123 reopened this Jul 12, 2022
@saisoma123 saisoma123 closed this Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants