lua-users home
lua-l archive

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


> Will lua 5.1 help?

No (unfortunately).


> Opinions? Suggestions?

If you really need that, you could try to create your own version of
"pcall" that runs its argument as a new coroutine. This new pcall
passes resumes and yields from one coroutine to the other and handle
errors when necessary. Something more or less like this:

  function mypcall (f, arg)
    local co = coroutine.create(f)
    while true do
      local status, val = coroutine.resume(co, arg)
      if coroutine.status(co) ~= "suspended" then
        return status, val   -- error or normal return
      else
        arg = coroutine.yield(val)   -- suspend across `mypcall'
      end
    end
  end

(This is untested code! I hope at least the concept is correct :)

-- Roberto