lupa icon indicating copy to clipboard operation
lupa copied to clipboard

Implement Lua operator overloading for wrapped Python objects

Open scoder opened this issue 10 years ago • 2 comments

Lua objects support operator overloading in their metatable:

http://www.lua.org/manual/5.3/manual.html#2.4

Mapping the Lua arithmetic etc. operators for wrapped Python objects to the equivalent Python operators should provide a much better user experience.

This also needs some kind of security support. Either through the normal attribute access intercept (which would have to check for special methods anyway), or through a separate set of explicitly allowed operators. Maybe both: explicitly allowed operators are fast, the rest goes through the special attribute lookup.

scoder avatar May 29 '15 10:05 scoder

Is there a way to do this at all right now?

noahcgreen avatar Jul 23 '20 03:07 noahcgreen

Is there a way to do this at all right now?

You can probably set up a metatable from Lua-side, so yes, it can be done, I think. Would just be substantially nicer to have it done automatically, since all the introspection capabilities are there.

scoder avatar Jul 23 '20 09:07 scoder