Skip to content

Add explicit scope support #36

@AdvancedAntiSkid

Description

@AdvancedAntiSkid

Is your feature request related to a problem? Please describe.
Housing actions are by design limited. As far as I can see, housing users use empty "if" statements to bypass these limitations. For example you can only have N variable assigns in a scope, so you create multiple ones in the same function.

Describe the solution you'd like
Decide whether to implicitly or explicitly handle scopes. Here is the tradeoff:

  • Explicit lets users decide how to organize their code, however they will have to make sure not to exceed action limits. Also introduces the question of variable shadowing: should a stat in a function scope be global to all child scopes, or should the stat names be mangled when shadowed; or disable redeclaration of stat in nested scopes.
  • Implicit allows the compiler to do smart tricks to introduce scopes implicitly when an action limit is exceeded. I will have to verify if randomly creating scopes have any runtime effect or not.
  • Hybrid mode would allow explicit declaration but will attempt to create scopes if a limit is exceeded.

Describe alternatives you've considered
I really do not prefer HTSL's explicit syntax of declaring an "if" without conditions. For compiler magic it is understandable, but end-user code looks so confusing because of this.

Additional context
If I decide to add variable shadowing then should consider creating compiler flags like "no mangle" or "rename" to allow users to have a say in the compiled stats' names. However considering how stats are mainly used in housing, it would likely be super confusing if shadowing became a thing, as stats are static/global.

Metadata

Metadata

Labels

compilerSomething regarding the compilerenhancementNew feature or requestsyntaxSyntax support for a feature
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions