Replies: 3 comments 1 reply
-
Actually, see dalexeev's own comment on the matter in #4721 (comment) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the clarification! I wasn't able to find these discussions in my first search. I thought the reason that the StringName operator was chosen to be like StringNames if I understand correctly are the equivalent of keywords in Clojure or symbols in Ruby, both of which use a notation like I think there's a usability for users familiar with StringNames vs confusion for users not-yet-familiar with StringNames balance to be found, but this could be addressed from a documentation perspective. Nodepaths like |
Beta Was this translation helpful? Give feedback.
-
If I understand correctly, StringNames have a literal form in GDScript, so writing
&"ui_accept"
generates the StringName for accepting ui. What I'm thinking is that it might be nice to be able to also write&ui_accept
to generate the same StringName.StringNames are often used for strings that do not have whitespace inside them, like names of methods in
Object.call
or action names inInput.is_action_just_pressed
.Currently writing
&ui_accept
syntax highlights it the same color as a proper StringName like&"ui_accept"
, even if&ui_accept
is a syntax error. So from a parsing perspective it should be a relatively simple addition. This also means that if you forget you need double quotes on StringNames, you run into a syntax errorThere may be confusion with the binary
&
operator, but usually string names, like identifiers, do not start with a digit, and the syntax highlighter seems fairly good at detecting when an&
is being used as a binary operator or as the start of a StringName. If string names starting with digits or with spaces are required, users would have no issue using the previous notation as&"42"
or&"Hello World!"
.This behavior would be similar to the not-literal
$
for accessing nodes, which can be currently used as$ChildNode
or$"ChildNode"
interchangeably.Beta Was this translation helpful? Give feedback.
All reactions