-
-
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
Guarantee that a static IntegerExp is never changed #9506
Conversation
|
Thanks for your pull request and interest in making D better, @Basile-z! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
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 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#9506" |
|
Isn't this doing what |
I believe so, but how does one properly express that with an |
|
Please, note that I've dropped the
I'm happy with the PR now so if you agree too with the change I'll just squash. |
|
|
@thewilsonator and others, squashed and forced pushed, merge to your appreciation but don't forget that the stuff is already there, this PR just improves it, since #9500 was merged before I address the review comment from @JinShil. 😉 |
| } | ||
|
|
||
| static dinteger_t normalize(TY ty, dinteger_t value) | ||
| void normalize() |
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 PR does not remove technical debt, it adds it. normalize() was a function that could be pure. It is refactored into a function that is not pure. I strongly object to this PR. Not only does it not do what the title says it does, I don't see a purpose to these changes, and none is offered.
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 see you did offer a rationale, making setInteger() private. I don't see a gain, though, as normalize() gets exposed instead. I don't see any improvement.
|
Closed because turning a pure function into an impure one is not where we should be going. Note that |
|
@WalterBright, please be aware that there is an issue with #9500. That PR introduced static singleton instances of You might argue that #9500 should not have been merged. @Basile-z even admitted that it was merged before he had time to address this issue. This PR was an attempt to address the issue. If this PR is not suitable, please suggest an alternative. |
|
I'm also surprised this got dismissed that quickly (although I would have killed |
And compilation time |
This follows up #9500, as suggested by @JinShil.
A bool flag is set when creating a static IntegerExp.It's used to make sure that neither the value nor the type are modified.Any attempt will lead to a ICE.Note a small drawback : before adding the flag the class instance size was exactly of 48 bytes.