lua-users home
lua-l archive

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

Moonscript is definitely interesting -- unfortunately I'm one of those programmers with strong opinions about what feels 'right' and 'wrong'.  I'm just not terribly in love with the languages that compile to other languages thing... 

This makes me [51%] happy for now :]

local import =
    function (t, ...)

        local pref, keys

        if select('#', ...) > 1 or (... ~= nil and type(...) == 'table') then
            keys, pref = ...
            pref, keys = ...

        keys = keys or {} 
        pref = pref or '' 

        if not next(keys) then
            for k in pairs(t) do 
                table.insert(keys, k) 

        local new_env = setmetatable({}, { __index = _ENV }) 

        for _, k in pairs(keys) do 
            new_env[pref .. k] = t[k]

        debug.setupvalue(debug.getinfo(1, 'f').func, 1, new_env)

import(string, { 'reverse', 'rep', 'sub' },'s')

print(sreverse('cat'), srep('donut', 5), ssub('abcdefg', 3, 6))


I mean it's touching _ENV, so I'm not happy... but I got the frontend I wanted.

On Tue, Nov 19, 2013 at 9:07 AM, steve donovan <> wrote:
On Tue, Nov 19, 2013 at 10:44 AM, Sir Pogsalot <> wrote:
> the community involvement with upstream is through this list and an overall
> attitude like this will probably hurt Lua in the long run.  Or maybe I'm
> just moping.. ~

I didn't see the response as particularly negative.  Precisely because
Lua is so carefully (and slowly) engineered, most of its fans require
a big leap in utility from any new feature.  And yes, a lot of us do
find the extra _typing_ tedious but just suck it up (or get clever
like Sean).  The reading I have no problem with, and my spell checker
will catch mistakes ;)

Every now and then I suggest people have a look at Moonscript, not
because I think it's _the_ future of Lua, but because it is _a_ future
of Lua - and it compiles to very straightforward Lua.  There is your
import feature there, 'locals-as-default', list comprehensions, really
concise lambdas and just about every 'it would be nice' feature I've
seen on this list. So it's an opportunity to try see how they feel in
practice. tlr;dr: a lot more syntax, and gotchas about local scope -
not for the newbie.

Unfortunately, I am too busy to contemplate marriage proposals at the
moment but the thought is appreciated ;)

steve d.