lua-users home
lua-l archive

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

Mike Pall wrote:
No surprises here -- more functionality comes at a price.

Caveat: this is a micro benchmark that measures only one tiny
aspect of the whole implementation. Overall Lua 5 is faster
than Lua 4.

Note that putting the plain table syntax back into Lua 5.1
would not be faster (the call overhead is still there).

The only realistic way to get back the Lua 4 speed is to
add a new syntax (which allows the lexer to distinguish the
two cases) and a new opcode. I'm not sure this pays off
when not doing micro benchmarks.

Syntax could look like this (riffing off of recent posts):

    for p from t do ... end

Here, t must either be a table or a userdata with a __iter() metamethod, allowing the great additional feature of being able to iterate userdatas!

chris marrin                ,""$,          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'