lua-users home
lua-l archive

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


On Mon, Apr 7, 2014 at 2:12 PM, Sean Conner <sean@conman.org> wrote:
It was thus said that the Great Christopher Berardi once stated:
> 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
>     ...

  I think I've mentioned this before, but why not extend the programming
editor you use to do the expansion for you?  I can certainly extend my
editor such that I highlight

        module5 func1 func2 func3

and have it (the editor) generate:

        local module5 = require "module5"
        local func1   = module5.func1
        local func2   = module5.func2
        local func3   = module5.func3

(or formatted however you like).  No changes to Lua, you get exactly what
you want.  Sure, if you "import" a library like "math" you'll get:

        local math       = require "math"
        local abs        = math.abs
        local acos       = math.acos
        local asin       = math.asin
        local atan       = math.atan
        local atan2      = math.atan2
        local ceil       = math.ceil
        local cos        = math.cos
        local cosh       = math.cosh
        local deg        = math.deg
        local exp        = math.exp
        local floor      = math.floor
        local fmod       = math.fmod
        local frexp      = math.frexp
        local huge       = math.huge
        local ldexp      = math.ldexp
        local log        = math.log
        local log10      = math.log10
        local max        = math.max
        local min        = math.min
        local modf       = math.modf
        local pi         = math.pi
        local pow        = math.pow
        local rad        = math.rad
        local random     = math.random
        local randomseed = math.randomseed
        local sin        = math.sin
        local sinh       = math.sinh
        local sqrt       = math.sqrt
        local tan        = math.tan
        local tanh       = math.tanh

but I see this as A Good Thing(TM)---you document exactly what you are
using and it's obvious to anyone using Lua what you are doing.

  -spc



Yes, in that vein I always preferred looking at post-processed C programs (cc -S).  I swear people here are crazy about avoiding convenience and concision.  Python's import() statements cause confusion to no-one who reads documentation on what a library provides.  If you don't recognize a stock global identifier it must be coming from somewhere ~  Whatever, we've had this discussion before -- Lua is just anti-convenience because everyone on this list is a feature-Nazi.  I cannot tell you how much those 20+ lines of local declarations bother me to skim -- and I have seen much larger, unmaintainable lists of declarations in the wild.