lua-users home
lua-l archive

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


Hi, I will thank you very much, because what you think is just I think.

I also think Lua is nearly perfect now, it's speed and clearly syntax
is very good, I don't want change Lua itself, I don't want e.g. Lua's
table have optional commas, etc. but the fact is some of part of Lua
is not very good, a example is, sometimes we need some complex
operations in express, so we do:
  local a = (function() local x = f() return x*x)() + 20
this is just Scheme does:
  (let ((a (let ((x (f))) (* x x))) ...)
because the let in Scheme is just a syntax sugar of (function(params)
... end)(args)。but Lua has least two issue:
  - first, this code in Lua will *create* a closure *every times* when
I execute it.
  - second, this code seems long and fuzziness, and the most important
is, this style *stop* the lua parser to optimize it!

So, the best way is: to makes Lua can meta-programming, i.e. makes Lua
can change the final compiled code when it get compiled!

I mean, I DON'T want change Lua anymore, only want before Lua compiler
compiles the code, I can change the code to a way that can be easily
optimize!

Lua can be used as a DSL, but if you don't want parse the DSL at the
runtime, you must makes this DSL to produce Lua code, and compile it.
I have develop a MMOPRG, it's protocol is define like this:
  command "Login" {
    args {
      field "name";
      field "passwd";
   };
   rets {
     struct "Player";
     struct "Bag";
     -- etc..
   };
}

But my game is running on a cellphone, these define will cost several
MB in memory, makes game run out its memory. so I have to makes
command and args and rets, etc to generate Lua code, and compiles
these code to luac to run on cellphone. with meta-programming ability
in Lua itself, I don't need write these generator module, and can use
it in Lua immediately. Yes, this is just LuaMacro done!

So many modules/softwares need this feature. metalua, moonscript,
YueLiang, LuaMacro, etc. I just want don't reinvent wheels, just makes
Lua can export it's lexer (Lua has not ast, And I think Lua is greate
because it don't have ast!). So why not to discuss how to add a simple
single interface in lua to just export its lexer? the other thing is
all up to the users of lua, not Roberto!

And, you know Lua is just open-source and *close-development*, I think
Roberto is much more wise to decide, just as wise he close the
development. just like metatable, if we can discuss a easy solution to
all this issues. I think Roberto can judge it. if not, Roberto will
has his wise judgement to not affects the Lua language!

I love Lua as it is, but I want it's better. I don't want to pile any
special feature into Lua, I just want find out a general purpose
solution to these issue, and ask Roberto add a simple easy interface
to Lua!

A example is, just add a mask LUA_MASKLEXER to lua_sethook, to makes C
user can modify the lexer token. or add a lua_setfilter to add a lexer
filter function. these solution are all not affects lua the language
itself, So why don't just discuss it?

2012/3/10 Dirk Laurie <dirk.laurie@gmail.com>:
>> 1 will makes lua has native meta-layer. but it needs careful
>> implement, and need roberto agrees.
>
>
> I'm not picking on the above in particular.  I quote it merely as
> one example of too many posts recently that want to change Lua.
> It gives the impression that lua-l is populated by people all
> unhappy with Lua in general and Lua 5.2 in particular.  All
> that when PiL3 has not even come out yet.
>
> Just to show that we are not all like that, I wish to say:
>
>     I like Lua the way it is!
>
> Roberto, Luiz, and Waldemar the Silent: keep it up just the
> way you always have.  It's great!
>
> Dirk
>
>