[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is Lua used as a data representation language?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 8 Jan 2013 15:10:23 -0200
> On Tue, Jan 8, 2013 at 5:31 PM, Ashwin Hirschi <email@example.com> wrote:
> > It doesn't seem to handle a simple case like:>
> > while 1 do end
> OK, thanks - I'll try to close some more gaps. The approach here is
> static checking, unlike the runtime limits Roberto suggests.
Another runtime aproach is this:
function loaddata (data)
local f = assert(loadstring("return (" .. data .. ")"))
local count = 0
count = count + 1
if count >= 2 then error"cannot call functions" end
local res = f()
count = 0
It only allows expressions (no variables, no assignments) and disallows
any kind of function calls.