Skip to content

Getters and Setters are both opt-in and opt-out, when they probably should be opt-outΒ #1263

@sylbeth

Description

@sylbeth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: registerRegister classes, functions and other symbols to GDScriptquality-of-lifeNo new functionality, but improves ergonomics/internals

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions