You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
const has an unintuitive and error-prone implementation.
A few open (there are more that are closed) issues related to the current definition of const: #56306 #52422 #61274
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Constant arrays and dictionaries should be made permanently read-only. A few days ago we got #61087 and #61127, allowing a simple mechanism. With being read-only, they'll be copied on assignment(? whatever is implemented these prs. I think it's copy on assignment) Consts would be constant expressions instead of one-time assignable variables, as the compiler expects. #820 would be a better fit for what const arrays/dictionaries are now.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
My take on the problem is Trioct/godot@b044060, making const arrays/dictionaries permanently read-only. This allows #41983 to be reverted as well, fixing #52422.
Example:
constx:= [3,2,1]
x.append(0) # Runtime error, x is read-onlyvary:=xy.append(0) # Works, x is copied to y. x remains unchanged.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Doesn't really apply.
Is there a reason why this should be core and not an add-on in the asset library?
Don't think this applies either.
The text was updated successfully, but these errors were encountered:
And to perhaps keep tbe current functionality (which I use greatly may I add), static could finally be used for variables as well?
static var won't be added in the interest of thread safety. Static variables generally don't provide much benefits when you have autoloads anyway. See godotengine/godot#6840 and in particular godotengine/godot#6840 (comment).
Describe the project you are working on
Typical simple project to test Godot 4.
Describe the problem or limitation you are having in your project
const
has an unintuitive and error-prone implementation.A few open (there are more that are closed) issues related to the current definition of const:
#56306
#52422
#61274
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Constant arrays and dictionaries should be made permanently read-only. A few days ago we got #61087 and #61127, allowing a simple mechanism. With being read-only, they'll be copied on assignment(? whatever is implemented these prs. I think it's copy on assignment) Consts would be constant expressions instead of one-time assignable variables, as the compiler expects. #820 would be a better fit for what const arrays/dictionaries are now.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
My take on the problem is Trioct/godot@b044060, making const arrays/dictionaries permanently read-only. This allows #41983 to be reverted as well, fixing #52422.
Example:
If this enhancement will not be used often, can it be worked around with a few lines of script?
Doesn't really apply.
Is there a reason why this should be core and not an add-on in the asset library?
Don't think this applies either.
The text was updated successfully, but these errors were encountered: