I would like to define a custom adding function for numbers.
Consider this string "return 1 + 2". This can be turned into a function with loadstring etc, but I can't override the behavior of "+".
I know I could write a different function for example "add2".
Then I would use "return add2(1, 2)". But this does not do what I want.
Metatables work wonderfully if I am using tables with __add.
Is there a way to use the metatable __add concept on numbers( and booleans)?
|