-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow const declarations on mutable fields #43305
Conversation
This is really cool, but removing myself from the review since I neither have the bandwidth nor expertise to meaningfully review this anymore. |
Is it more common to have a few mutable fields instead of a few const fields? Maybe it could make sense to have e.g.
instead of having to do
? Or perhaps support both... |
class A
{
public:
A() : x(4), y(5) { };
mutable int x;
int y;
};
int main()
{
const A var2;
var2.x = 345;
// var2.y = 2345;
} |
Not sure, a mutable struct with some fields marked const is still mutable, while the opposite is not true (immutable struct with mutable field is no longer immutable) so to me it makes more sense to have the annotation be a restriction. |
While I kinda agree (we are used to interpret |
In that case would these two be equivalent? mutable struct Foo
a
b
end
mutable struct Foo
mutable a
mutable b
end |
Mark some builtin types also, although Serialization relies upon being able to mutilate the Method objects, so we do not yet mark those. Replaces #11430 Co-authored-by: Matt Bauman <mbauman@gmail.com>
5a9a34e
to
5ceefe4
Compare
I agree with Kristoffer that adding a mutable field to a struct is a more dramatic change than restricting a field of a mutable struct to constant. The problem is that |
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294.
This reverts commit 63f6294. Revert "Make BitSet field const (JuliaLang#43553)" This reverts commit 98b485e.
Mark some builtin types also, although Serialization relies upon being able to mutilate the Method objects, so we do not yet mark those. Replaces JuliaLang#11430 Co-authored-by: Matt Bauman <mbauman@gmail.com>
Mark some builtin types also, although Serialization relies upon being able to mutilate the Method objects, so we do not yet mark those. Replaces JuliaLang#11430 Co-authored-by: Matt Bauman <mbauman@gmail.com>
Mark some builtin types also.
Replaces #11430
Co-authored-by: Matt Bauman mbauman@gmail.com