Unset or delete global variables
It would be nice to be able to completely erase global variables once they are no longer needed by the story, such as after passing through a one-way transition at the end of a "chapter", with perhaps an (unset: bind $variable)
or (delete: bind $variable)
macro or some construct like (set: $variable to nil/null/nothing)
. Technically this could be useful for temp variables in some circumstances, but less so generally as they already clean themselves up.
This can trivially be simulated by setting the variable to ""
, 0
, (a:)
or some equivalent empty structure. But it still exists in the global scope, is still cluttering the debug view, and is still saved along with the game's state.
Less intuitively, though more correctly, you can use [(move: $variable to _temp)]
and cause _temp
to immediately fall out of scope; however it's not very obvious at first glance that this is what it's doing, and it could be easy for a later edit to "optimize" away a supposedly unnecessary assignment to an unused variable. With the upcoming changes to temp variable shadowing, this construct could get even more sticky if deletes in nested hooks are required, needing different throwaway names for the inner hooks. Adding a dedicated macro or assignment construct that clearly indicates the variable is to be removed would make this both safer and entirely unambiguous.