lua-users home
lua-l archive

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

> The problem with this is that I can't see a way to check if the expression
> evaluates to nil or that dostring() simply returns nil because of an error.

You can check the 2o result from dostring (it returns an error code when
there is an error). Better still, you can pre-compile your expression:

  f = dostring(format("return (function () return %s end)", exp))
  if f == nil then syntax-error end
  exp_value = f()      -- evaluate expression

-- Roberto