lua-users home
lua-l archive

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


The Lua VM is too big. I have an idea of how to make it smaller, with 2 breaking changes and 2 backwards-compatible changes:

Breaking changes:
1. Remove OP_ADD (use `-(-x-y)` instead) [breaks/removes `__add` metamethod]
2. Remove OP_MUL (use `x/(1/y)` instead) [breaks/removes `__mul` metamethod]

Compatible changes:
1. Turn for loops into syntax sugar, remove OP_FORPRER and OP_FORLOOP (which can be used to break out of sandboxes), OP_TFORLOOP (the opcode for `for ... in ...`) [1] 2. Remove OP_SELF (this might make it a bit slower but `table:whatever()` can be done without OP_SELF by using OP_MOVE)

[1] Would also make it possible to use numeric for loops (aka `for x=a,b,c`) with non-numbers (as long as they override __add, __eq, etc)