Replies: 4 comments 6 replies
-
You can put polls in discussions?? Also I would prefer val since it's what Kotlin uses and I like Kotlin, and I think it effectively communicates the difference between a mutable variable and a read-only value. |
Beta Was this translation helpful? Give feedback.
-
In my humble opinion, I agree with sockeye-d, Failing that, EDIT: |
Beta Was this translation helpful? Give feedback.
-
Important UpdateThere's a discussion that may lead to a potential decision from devs to get rid of prefix keywords entirely, moving all of them to annotations (it's possible even So, when voting, keep in mind that the prefix keyword variation might not be an option.
func set_node(let node: Node) -> void:
let parent = get_parent()
func set_node(@readonly node: Node) -> void:
@readonly var parent = get_parent()
# or
func set_node(readonly node: Node) -> void:
readonly parent = get_parent()
func set_node(val node: Node) -> void:
val parent = get_parent()
func set_node(final node: Node) -> void:
final parent = get_parent()
# or
func set_node(@final node: Node) -> void:
@final var parent = get_parent() Assuming there would be a syntax to make parameters immutable. So note that, if going with a standalone keyword variant, I don't know if devs would exceptionally allow it as prefix on parameters, or use some other syntax for immutable parameters (e.g. make it an annotation too), or just not implement immutable parameters (like in JS) as shallow immutability on pass-by-copy parameters is just an implementation nicety, irrelevant wrt. the exposed API (doesn't affect the function signature). |
Beta Was this translation helpful? Give feedback.
-
Poll results(I intended to close it on 19th, but Google Calendar didn't notify my reminder for some reason, so I'm closing it now) Total votes: 40
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
GDScript currently uses a
const
keyword for compile-time constants. It may be getting support for immutable variables (runtime constants) too, but a consensus from the community is desired to decide on the syntax:I have previously posted a preliminary informal poll with 8 suggested options. It was only intended as a starting point -- since it allows duplicate voting, and some options would split voting among similar syntax, I felt like it should be done more properly here.
Now that it gathered a good amount of votes, this is a more "formal" poll with a reduced set of options (half) from before as a second round. The 2 most voted choices then move on to a last round, probably about a month from now. So, even if you have multiple options you like or dislike, vote for your best preference without worrying about it, as you may vote on your secondary preference later.
This poll is about what the word itself should be. Whether it should be a prefix keyword to
var
, a standalone keyword or an annotation could be as recommended here, but that is secondary in this poll.Disclaimer: I'm not a member or contributor of the repo, so treat this as a non-official "community" poll, for reference only.
Suggested syntax options
Informational only, doesn't necessarily mean all features would be supported as shown.
let
Proposing it as a standalone keyword. Unlikely to be fit for a prefix keyword or annotation.
readonly var
|@readonly var
|readonly
Showing syntax as a prefix keyword. Could be discussed as annotation, or even standalone keyword.
val
Proposing it as a standalone contextual keyword. Unlikely to be fit for a prefix keyword or annotation.
This option is on the assumption a contextual keyword can be used so
val
doesn't become a reserved word.final var
|final
|@final var
Showing syntax as a prefix keyword. May be preferable as a standalone keyword without
var
, or even as annotation.Considerations
You can read the posts in #820 for the community's considerations regarding familiarity from other languages, succinctness/verbosity, explicitness of its meaning, risk of clashing, risk of confusion, personal preferences, etc.
40 votes ·
Beta Was this translation helpful? Give feedback.
All reactions