i agree, and almost included that list in my reply. but i didnât, mostly because this really should be generated from ldoc.
these globals are all declared in startup.lua (i hope!) and are mostly includes of commonly needed modules:
[ https://github.com/monome/norns/blob/master/lua/startup.lua#L9-L31 ]
except - oh dear - there are more. a lot more. they are in script.lua and all over the place. iâm taking this to github.
so, iâm probably a broken record at this point, but i donât think any of these really need to be global, and some of them really arenât going to be used much at all (wifi).
but g is really the odd one out. is it really, really necessary for it to be global and a single letter? could be a field in the grid module, requiring the single line local g = grid.g? (or better, something descriptive like local g = grid.default_device.)
as it is, kind of assumes that the absolute most important first thing that every script will do is get a handle to the default grid device. (like s in supercollider for the default server.) if thatâs the assumption than why not have e for engine, s for screen, at the very least⊠since almost every script will use those.
sure, convention for globals isnât a bad idea. lua already has some internal conventions and predefined globals. all-caps plus preceding underscore represents some important ones: _G for the global environment, _VERSION, &c.
a soft convention weâve used so far is initial capital in Modulename. (but usually assigned to a lowercase modulename when included.)
oh thatâs interesting, i donât think i ever even assumed that declaration order would not matter. is this a javascript thing? (you donât have to hoist anymore?)
ok, last thought re: scope and then iâll stop banging on about this
could be worth linking to lua style guide
http://lua-users.org/wiki/LuaStyleGuide
and maybe the scope tutorial.
http://lua-users.org/wiki/ScopeTutorial