Skip to content
Discussion options

You must be logged in to vote

I don't think this is a good approach. Emmylua's static analysis can almost directly detect unintended global variable definitions. Also, locking global variable definitions using _newindex is not suitable during the loading phase. A better way is to allow global variables to be defined directly while files are loading, and then set the metatable for G after loading is complete. This way, you don't need to use a function like SET_GLOBAL to achieve this.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Polanas
Comment options

@CppCXY
Comment options

@Polanas
Comment options

@CppCXY
Comment options

Answer selected by Polanas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants