lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


There's no obvious reason to patch require in C; why not patch it in
Lua? Write your own require which calls the original require, and, if
it fails, does its own thing, loading a built-in string or whatever:

local old_require = require
function require (module)
  local ok, m = pcall (old_require, module)
  if ok then return m end
  ... -- try getting module from internal strings
end