lua-users home
lua-l archive

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


> I would like to submit a request to the creators of Lua that they not go
> down the path of turning Lua into Ruby.  Given how simple it actually is to
> add all this stuff for those who want it, both from the C side of the fence
> and the pure-Lua side, I'd prefer to see Lua kept lean and clean.  People
> who want to have Lua-flavoured Ruby (or Ruby-flavoured Lua) can easily make
> a library (call it Corundum or the like) that does all this without
> polluting the main distribution.  Toss it up on Github or Bitbucket and you
> can even let the whole Rua (or is it Luby?) community go nuts on it and
> replicate the Ruby landscape in Lua to their heart's content.
> Of course we could turn Ruby into Erlang instead....

So shall I start github and submit these 6 lines of "code"?

-- setup
debug.setmetatable(0,{__index = math})
debug.setmetatable(coroutine.create(function()end),{__index = coroutine})
-- tests
assert(math.pi:floor() == 3)
assert(cooroutine.create(assert):status == "suspended")

including an "experimental patch" (because I don't know what it could
be good for...)
> debug.setmetatable(function()end,{__index = {call = function(f) return f() end}})
> (function() print "blah" end):call()
blah
> debug.setmetatable(nil,{__index = math})
> =(nil).pi
3.1415926535898

Because that's all that is needed to get it working. It's not complex
at all from Lua's point of view (question: have you been aware of this
simplicity or that Lua is already this rub(b)ish? I would be glad to
know having increased someone's Lua knowledge ;)).
The true question remains, if a unification (every type a metatable)
would reduce code in size (less ifs), thus in complexity (less ifs)
and maybe even equal or better performance (less ifs). Maybe the code
is already completely like what I am asking for, except that some
types just don't have metatables... (though maybe we could avoid a few
ifs...?).

What I want to point out: I do not want ruby, nor OOP nor anything
like that. I am just asking: could such a change not be an advantage
even by the criterias that you do have? I clearly haven't read the Lua
sources close enough to know anything about metatable checking during
execution, all I know is, that there's already a metatable check for
any type and value (not sure about light userdata but I would be
surprised if they don't have a metatable check) and that connecting a
metatable with these types works perfectly already.
>From my own coding experience, I almost always expect that a
unification is to the benefit of code size and in not few cases, it
also means less processor cycles per execution, thus more speed (so,
matching your criterias of "Lua (being) kept lean and clean (...)")

So please try to be objective instead of writing

> (...) let the whole Rua (or is it Luby?) community go nuts on it and
> replicate the Ruby landscape in Lua to their heart's content.

... and don't be afraid of _not_ making

> (..) a request to the creators of Lua that they not go
> down the path of turning Lua into Ruby.

, because the Lua creators are highly experienced in turning down
requests on their own if they don't like it. I know this from  second
and first hand experience. Trust me ;)

Cheers,
Eike