is it ok to put key variables as a Global _G? (re best practice)

Re best practice, is it OK to put key variables as a global (_G) to allow easy access throughout your application? Would alleviate the need to have to “require” them in each file you’re using them in.

For example say:
* you model variable (that stores details of objects)
* a Utils set of functions

As an example:

-- Main.lua  
\_G.Utils = require("common/utils")  
-- Elsewhere  
local testTable = {["A"] = "test", ["B"] = "array"}  
Utils.dump("TEST ", testTable, 10)  

[import]uid: 140210 topic_id: 25748 reply_id: 325748[/import]

Depending on how the code is written you may not need to use _G. at all - take director for example, you require in main and not again. Same with Ego.

You should read Jon’s blog posts on modularization, they have some great tips for this stuff :slight_smile: [import]uid: 52491 topic_id: 25748 reply_id: 104174[/import]