lua-users home
lua-l archive

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

2011/3/31 steve donovan <>:
> Yes, although to handle full complex arithmetic you must parse such
> expressions into some AST form in order to generate the real and
> complex parts of the expression.  A bit messy, but the performance
> benefits would be worth it.[1]
> It doesn't feel like something that should or needs core changes -
> more like a supercharged preprocessor with MetaLua-like capabilities,
> but emitting Lua code for LuaJIT, etc.[2]

I agree with you. I'm converging toward a solution: write a new parser
for a modified Lua language that will generate and AST to be given to
LuaJIT. I'm more and more persuaded that this can be *the* good
solution. I will be able to solve also other major problems like:
- a simple syntax to access matrix elements like m[2,3]
- how to have postpone arithmetic operations to optimize the whole
expression (lazy evaluation)
- elimination of cdata/userdata duality => only cdata can be used
because the low level details will be hidden to the final user

This new language will be therefore like Lua but with native support
for matrix and complex numbers and it will be based on LuaJIT2 to
generate fast code. It sounds to me *very* promising. Unfortunately
there is a lot of work to do to realize it. Basically I will need to
- rewrite a LuaJIT2 parser so that we add an additional step that uses
the AST between the parser and the code generator:

   parser <-> AST <-> code instrumentation

- write a parser for my language that generate an AST to be given to
the AST => code generator.

This new language could be called ForLua :-)