lua-users home
lua-l archive

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


> You could patch Lua, but it's that way for a reason. Speed. Having to check 
> metatables for every single addition, having to remove the optimized for 
> loops and constant folding, etc. Possibly worse still is what the functions 
> would look like.. having to add a rawadd, rawsub, rawmul... yuck.

I agree that this would ugly.   I'm just trying to understand metatables better.

I was trying to use metatables to create a abstract syntax tree (AST) like lisp
from lua code. I was getting fairly far until I hit this snag for numbers and
boolean variables.  If my code only uses tables or a table for 1 of the 2
operands for binary operations, it works fine.   With an AST, I could do some
static code analysis.