[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua is too big
- From: "Thiago L." <fakedme@...>
- Date: Wed, 11 Jun 2014 12:59:45 -0300
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)