Skip to content
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

Rename public vars to avoid conflict with library user scope #751

Open
offalynne opened this issue Jul 28, 2023 · 0 comments
Open

Rename public vars to avoid conflict with library user scope #751

offalynne opened this issue Jul 28, 2023 · 0 comments
Labels
upstream bug 💧 YYG strikes again workaround 🔧 Temporary fix for upstream bug
Milestone

Comments

@offalynne
Copy link
Owner

offalynne commented Jul 28, 2023

GML has some peculiar quirks regarding scope that make library authorship a challenge. Specifically, there are at least three situations in which a variable name is always reserved, and will override instance and local variables when referenced. These are:

  1. Asset name
  2. Globally scoped function name
  3. globalvar name (Deprecated)

For any expression where a library references a variable name as a value, for example type in the expression thisType = type, any of the above 3 cases will result in behaviour undefined by the library, where thisType will be assigned the value of the asset reference, function reference, or globalvar value of type instead of the value of the local or instance variable of the same name as expected.

There is no great solution for this so Input will settle for a compromise -- library variables will be prefixed with two underscores (usually reserved to indicate "private" variables) even when they are exposed by the API as public struct members, as for example with input bindings.

This change is a large effort that touches many corners of the project and will be rolled out gradually.

@offalynne offalynne added this to the 7.0 milestone Jul 28, 2023
@offalynne offalynne modified the milestones: 7.0, 6.3 May 27, 2024
@offalynne offalynne pinned this issue May 27, 2024
@offalynne offalynne changed the title __privatise class fields Rename public variables to avoid conflict with library user scope May 27, 2024
@offalynne offalynne changed the title Rename public variables to avoid conflict with library user scope Rename public vars to avoid conflict with user scope May 27, 2024
@offalynne offalynne changed the title Rename public vars to avoid conflict with user scope Rename public vars to avoid conflict with library user scope May 27, 2024
@offalynne offalynne added upstream bug 💧 YYG strikes again workaround 🔧 Temporary fix for upstream bug labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream bug 💧 YYG strikes again workaround 🔧 Temporary fix for upstream bug
Projects
None yet
Development

No branches or pull requests

1 participant