|
Greg Hill wrote:
Hmmm... yes... one cannot overwrite the primitive 'add' when both operands are numeric:Can this be done with the C API or by patching lua?
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.
If you insist, start in lvm.c - look for arith_op and Arith(); besides from constant folding and for loops all you need is there.
- Alex