[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Turing-incomplete Lua?
- From: Diego Nehab <diego@...>
- Date: Wed, 1 Dec 2004 15:15:38 -0500 (EST)
Hi,
> this:
> ----------
> function a(b)
> return a(b)
> end
>
> a(1)
> ----------
>
> And variations with multiple functions doing recursion,
> or this:
>
> while length==1 do print(length) end
You can't possibly detect whether these would happen in a generic Lua
program. If you could, you would be able to solve the halting problem,
and the universe would colapse. Even if you could, it would have no
practical application, as someone else noticed, because even a loop that
is not infinite might be infinite within your life-spans. Seems like you
want is to prevent a Lua script from running for too long and this has
nothing to do with Lua being Turing complete or not.
To achieve this, all I can think about is setting a hard-limit
on the number of instructions the interpreter can run, on operations that
could cause the OS to block the interpreter (like asking for input), and
on single operations that could take too long (like allocating a large
chunk of memory, or flooding the hard disk with information).
I still don't understand why you would want to do these things, though.
Seems like you have two goals that are fighting each other. You want to
let your scripts do things that are dangerous (like looping, allocating
memory, writing to files) but you don't trust them to do it right.
Regards,
Diego.