i agree, and almost included that list in my reply. but i didn’t, mostly because this really should be generated from
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 (
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,
a soft convention we’ve used so far is initial capital in
Modulename. (but usually assigned to a lowercase
modulename when included.)
ok, last thought re: scope and then i’ll stop banging on about this
could be worth linking to lua style guide
and maybe the scope tutorial.