Re: Evaluating expressions, not statements?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Evaluating expressions, not statements?
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2001年4月05日 15:06:50 -0300
> 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