You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, builtins and APIs are simply exported via _G.SomeObject = SomeObject. While that works, it will be very difficult to ever change the behavior across the entire codebase. It's also annoying to test, since messing with the global environment without following a predefined protocol could have plenty of unintended side effects.
To that end, all global exports that exist on purpose, i.e., are not "leaked globals", should follow the following convention:
EXPORT("SomeObject", SomeObject)
where
function_G.export(name, objectToExport)
-- Sanity checks, etc and print warning if it already exists?-- log TRACE("Exported global SomeObject" ?-- etc._G[name] =objectToExportend
This consolidates all modifications of the global environment and provides a streamlined way of doing so that allows mocking (for tests), documenting automatically (scan for export calls), and refactoring/changes in the design (search for export calls in the code).
The text was updated successfully, but these errors were encountered:
Currently, builtins and APIs are simply exported via
_G.SomeObject = SomeObject
. While that works, it will be very difficult to ever change the behavior across the entire codebase. It's also annoying to test, since messing with the global environment without following a predefined protocol could have plenty of unintended side effects.To that end, all global exports that exist on purpose, i.e., are not "leaked globals", should follow the following convention:
where
This consolidates all modifications of the global environment and provides a streamlined way of doing so that allows mocking (for tests), documenting automatically (scan for export calls), and refactoring/changes in the design (search for export calls in the code).
The text was updated successfully, but these errors were encountered: