|
It depends on what you intended to achieve with monkey-patching. Did you really mean to change the behavior of all code using a certain function internally (even those whose implementation you don't know) or do you want to enhance an existing module/function to make your own programming more expressive. If it's the latter (which I assumed), the code that has already been written and tested with the old behavior in mind will not benefit. But it _can_ break (popular example: someone enhances `type` to return class names for objects, and some other module uses the result of `type` in a lookup table)! If on the other hand you want the first, to patch some error without fixing the source code, you can still do that, but it requires the `debug` module (but that's ok, because you are _actually_ debugging ;-) ). Also on the plus side: you can replace some function _for certain modules only_. (If you mean serious business, you could also monkey-patch before the module in question captures its env, e.g. first thing in the main script.)
I always meant to try Löve, but I've never got around. It uses zip files for storing modules, right?
`my/module/init.lua`. If it is require'd as `require "my.module"`