Extensions and global variables


#1

I think it would be a good idea to enforce a few rules regarding extensions. Like no pollution in the global variables scope, everything should reside inside extension’s table. And I like how in Corona every plugin is prefixed with plugin.* When you read source code and see plugin.something you know it’s a plugin and not some strange global variable. For defold it could be ext.*. That would elliminate any possible clashes of extensions between themselves and user code.
So ext.camera, ext.admob and so on. And the global variables scope would stay clean.
What do you think?


#2

It’s still possible to create two extensions that clash.

But it’s perhaps not a bad idea to tell people to prepend their extensions with “ext.”
We can perhaps update the readme on this part. I’ll discuss this with the team as well.


#3

Another idea would be to encourage people to make their extensions require-able instead of adding tables to the global scope. But I think you’d need some extra APIs for that (or just drop it to the global scope with an obfuscated name, then make a lua file that exposes it).