lua-users home
lua-l archive

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


On Mon, Apr 7, 2014 at 10:32 AM, Coroutines <coroutines@gmail.com> wrote:



On Mon, Apr 7, 2014 at 10:18 AM, Christopher Berardi <cberardi32@gmail.com> wrote:

On Apr 7, 2014 12:57 PM, "steve donovan" <steve.j.donovan@gmail.com> wrote:
>
> On Mon, Apr 7, 2014 at 6:43 PM, Christopher Berardi
> <cberardi32@gmail.com> wrote:
> > I would like to see a comprehensive (3rd party) math library for Lua, one
> > that could be used for a wide variety of mathematical disciplines instead.
>
> Well, there's lhf's lmathx, binds the extra C99 functions.  Then
> things get ... complicated, because people have different mathematical
> needs.

Getting a common and useful subset for a sizable userbase is the tricky part. Or, fill a niche market. My areas of interest are not the same as other peoples which are different yet again from some else. But a stab at it may give me something to do.

> > I'll also put myself with those who want a more robust and expressive
> > require function.
>
> But precisely what does this mean?

For one example of expressiveness, and I know its been beaten to death before, would be akin to Python's import statement:
    import module1
    import module2 as m2
    import module3, module4
    from module5 import func1, func2
    ...

This is something I have posted about (in want of) before.  Here is what I came up with:  https://github.com/Pogs/lua-snippets/blob/master/import.lua

It works by declaring globals, not locals.  Locals are allocated at compile-time (when Lua source becomes Lua bytecode).  If require were made into a Python-like import it would be nice if it could support this form for declaring and assigning locals (your last example).  My import.lua works mostly for the "make your own _ENV" way of doing that.  In fact I almost want to call it table.import().

~ hope that helps ~

Er, some clarification on what I said about the last example you gave: from module5 import func1, func2  would be similar to local func1, func2 = require('module5').func1, require('module5').func2

The tricky part is when you 'import module1' and make all the functions "exported" by module1 into locals (not globals).  -- I feel like I'm going to have to defend the "why locals?" position in a few replies...