lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Apr 8, 2014 at 5:07 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
On Tue, Apr 8, 2014 at 12:51 PM, Christopher Berardi
<cberardi32@gmail.com> wrote:
>         import module1
>         local import module2

The first form could be implemented simply as a function, since it
just involves a loop at run-time copying key,value pairs from the
require'd module into _G.

The second form has to expand at compile-time, and in general this
isn't possible, because we don't know what the contents of 'module2'
are at compile-time.

> And the same for getting sub-modules
>
>   import func1, func2 from module4
>   local import func3, func4 from module5

I doubt there's any need for the first form here - the second form can
be implemented at compile-time (or macro expand time) because the
names are specified.

One way of evaluating a proposal is to think of documenting it, and I
think it's going to take a fair amount of text to explain this all....

It's matter of what's easy to type and what's easy to read;  if the
typing is a problem, teach your editor to do the expansion, if reading
is a problem..... well, then I don't know..  Personally I don't see
the problem with reading explicit code. This feels like an attempt to
impose another language's semantics onto Lua - as well as syntax.


Your last statement frustrates me.  I could see "new syntax" being scary, but another languages' semantics?  Are you kidding?  How is it another language to essentially pull in references in batch from one table to another?  Tired of this crap.  Every. single. time.  Someone posts about having the slightest convenience it gets shot down as lazy, something not-Lua, or feature-creeping.  I wrote this topic before and it never even got to the "this is a hack but it works" phase -- it was just endless replies about laziness and "I have no problem reviewing code explicitly".  This is the best that can be done currently: https://github.com/Pogs/lua-snippets/blob/master/table-import.lua

It's handicapped in that it of course can't make locals.

Some of you act like you've never seen a 20-30 line list of local declarations that you hope aren't full of typos.  Of course you can expand it as a macro with another script or with your editor but it still leaves the list in its post-processed form for someone else to review and wonder if you did it by-hand or generated it.

This thread should die already -- I doubt anyone is going to add more commentary for what should happen to the math lib.  2014 on lua-l is the era of circle-jerked threads.