Programming language for self-modifying code?

后端 未结 14 1746
别那么骄傲
别那么骄傲 2020-12-23 13:05
  • I am recently thinking about writing self-modifying programs, I think it may be powerful and fun. So I am currently looking for a language that allows
14条回答
  •  無奈伤痛
    2020-12-23 13:36

    In Lua, you can "hook" existing code, which allows you to attach arbitrary code to function calls. It goes something like this:

    local oldMyFunction = myFunction
    myFunction = function(arg)
        if arg.blah then return oldMyFunction(arg) end
        else
            --do whatever
        end
    end
    

    You can also simply plow over functions, which sort of gives you self modifying code.

提交回复
热议问题