Code Monkey home page Code Monkey logo

colony-lua's People

Contributors

johnnyman727 avatar tcr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colony-lua's Issues

Arithmetic metamethods never invoked in Lua environment.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.