-
-
Notifications
You must be signed in to change notification settings - Fork 287
Getters and Setters are both opt-in and opt-out, when they probably should be opt-out #1263
Copy link
Copy link
Closed
Labels
c: registerRegister classes, functions and other symbols to GDScriptRegister classes, functions and other symbols to GDScriptquality-of-lifeNo new functionality, but improves ergonomics/internalsNo new functionality, but improves ergonomics/internals
Milestone
Description
The getters and setters when defining variables are opted-out of when specifying one of them, but then they're opt-in when you specify the second. This creates an error-prone framework when defining properties, as such, based on @Bromeon's comment: #1151 (comment), @ttencate proposed the following API (for getters, but it's symmetrical for setters, now both being independent of one another):
- No
#[var]: No getter. #[var]: Default getter.#[var(get)]: Custom getter with default name.#[var(get = name_of_fn)]: Custom getter with custom name.#[var(no_get)]: No getter
To this, I want to bring again that if needed to change the default getter's name, the only way to do so is by making a custom one. For that I propose the following two:
#[var(default_get)]: Default getter.#[var(default_get = name_of_fn)]: Default getter with custom name.
These last two are not necessary, but if they are deemed useful they should be easy to implement.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: registerRegister classes, functions and other symbols to GDScriptRegister classes, functions and other symbols to GDScriptquality-of-lifeNo new functionality, but improves ergonomics/internalsNo new functionality, but improves ergonomics/internals