tessel / colony-lua Goto Github PK
View Code? Open in Web Editor NEW[UNMAINTAINED] Lua 5.1 branch
License: Other
[UNMAINTAINED] Lua 5.1 branch
License: Other
Commit 5cc396f prevents any arithmetic metamethods from being invoked thereafter. I can't find any way to overcome this or restore the original behaviour in the environment, therefore a fix would be appreciated. Metamethods are a very powerful tool, especially when implementing different coercion rules and it's a shame to lose the ability to use them in the runtime.
This code highlights the issue:
do
local mt = {
__add = function (a,b) print ('ADD CORRECT!') return 123 end,
__sub = function (a,b) print ('SUB CORRECT!') return 123 end,
__mul = function (a,b) print ('MUL CORRECT!') return 123 end,
__div = function (a,b) print ('DIV CORRECT!') return 123 end,
__mod = function (a,b) print ('MOD CORRECT!') return 123 end,
__pow = function (a,b) print ('POW CORRECT!') return 123 end,
__unm = function (a,b) print ('UNM CORRECT!') return 123 end
}
local x = setmetatable({}, mt)
print(x + x)
print(x - x)
print(x / x)
print(x * x)
print(x % x)
print(x ^ x)
print(-x)
end
Expected (Lua 5.1):
ADD CORRECT!
123
SUB CORRECT!
123
DIV CORRECT!
123
MUL CORRECT!
123
MOD CORRECT!
123
POW CORRECT!
123
UNM CORRECT!
123
Actual:
nan
nan
nan
nan
nan
nan
Add code of conduct badge, a la tessel/project#190
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.