lua-users home
lua-l archive

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


> if it does not cache scripts, is there some easy and efficient way to
> implement this?

If you're loading scripts from files, try this:

 do
  local T={}
  function run(s)
   local f=T[s]
   if f==nil then
    local e
    f,e=loadfile(s)
    if f==nil then return f,e end
    T[s]=f
   end
   return f()
  end
 end

Of course, this code assumes that files will not change once they loaded.
--lhf