-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Simplified StringName literal for single word text #8079
Comments
I had a similar idea, but after some thought I concluded that this syntax might confuse users that there are pointers/references in GDScript: node_2d.set(&global_scale, Vector2(8, 2.5))
tween.tween_property($Sprite, ^position, Vector2(100, 200), 1) The quotes more clearly indicate that these are just strings: node_2d.set(&"global_scale", Vector2(8, 2.5))
tween.tween_property($Sprite, ^"position", Vector2(100, 200), 1) |
Yeah. It first sounds good on paper but by all practical means, StringNames are Strings and a vast majority of users wouldn't want to even realise there's a distinction between the two, let alone seeing a somewhat "magical" symbol behind what is just one character away from referring to the value of a property. |
Duplicate of #4721 ;)
Note that currently Dictionaries will implicitly convert StringNames to Strings, making them actually slower: godotengine/godot#68834 |
I am ok with it being not happening and getting closed, as people coming from C++ background will mistake as a referenced variable rather than StringName (not String), which is actually it is. From #4721 I only got, that it was closed because nobody wants to add more colors, although few people liked the proposal. This is disappointing. |
#4721 is not closed and the colors were actually implemented. The syntax is still being discussed. |
Describe the project you are working on
Casual Game in 4.2
Describe the problem or limitation you are having in your project
Currently the StringName literals are identified as
&"hello godot"
. It is well and fine.For single word text, can it not be simplified by removing the quotes similar to Node Path like
&hello_godot
Describe the feature / enhancement and how it helps to overcome the problem or limitation
It will help in reducing unnecessary quotes as in NodePath
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Support both the structure for String Name as given below
If this enhancement will not be used often, can it be worked around with a few lines of script?
It will be used mostly as constants and keys to dictionary, where the text is not changing.
Is there a reason why this should be core and not an add-on in the asset library?
GDscript parser is part of core.
The text was updated successfully, but these errors were encountered: