I want to thank Petite Abeille for being the most contributory, the 2nd approach was creative. I would probably stick with the from() I posted, but I thought your code was really thought-provoking and I appreciate you putting more code to this thread. :]
Most of the replies boil down to:
1) don't add more syntactic sugar
2) add the 'local a, b, c in some_module' patch to 5.3
3) modify _ENV
4) have an external script generate the 'local a = mod.a' list
5) "why does this idea keep coming up?"
6) would encourage "fat" bytecode and shadowing problems
My response:
1) I didn't suggest adding syntactic sugar, I am not proposing that
2) I do like that patch but ^
(also, local a, b, c in modname removes the ability to add a prefix to the identifiers)
3) I said in my original email that modifying _ENV is not always a good idea
4) Running an external script to generate the preamble sounds trendy...
5) There must be some reason around here...
6) This one has some merit, but I'd rather let users shoot themselves. :3
Just want to add that I use Lua because of its simple grammar. The performance and small distribution size is definitely nice, but what I like most is how I can show Lua to people who don't know Lua and it's pretty easy for them to understand what's happening. I don't get that with Python or Ruby or Perl... especially Perl. My point being: I love Lua for being a very "clear" language. Most of the pseudocode examples resemble Lua and that's a great thing. It's not as concise as Python, but it does save keystrokes compared to languages like PHP or Perl. I use Lua because it's simple to understand and it does save me keystrokes. The problem is these local lines. I see a lot of them and they're not easy to 'skim'. It makes it difficult to review others' code if you're making sure they use everything they've referenced. Most people don't even do it to avoid table lookup times, it's just to avoid writing "string." or "table." everywhere. It's both a conveniency issue and a readability issue (imo). The could be better but *exactly* what I want doesn't sound possible with how locals are currently allocated at compile time.
Things to remember:
- I'm trying to avoid messing with _ENV
- I'm trying to create locals in batch
- I want to create locals [not globals!!!] with import()
- I want the ability to provide a prefix to the generated local identifiers
- I want to be able to specify a list of what to localize from the table
Anyway, I'm outtie. :]