lua-users home
lua-l archive

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


> Is there any reasonably easy way to use Lua as a data-
> description language, while disallowing the features
> that make it a Turing-complete language?

I'm not sure that's what you mean, but if your data description is a series of
expressions, you may be able to do what you want by simply prepending "return "
to the file before compiling. This will avoid all procedural constructs in
the main chunk.

However, itt won't be completely safe because you still write things like
	return (function () for i=1,10 do print(i) end end)()

To handle these, you could set up a call hook and raise an error at run time.
(You still need to allow the chunk to run, and this is a function call; so
you need to disallow nested functions calls.)
--lhf