[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Next Version of Lua?
- From: David Given <dg@...>
- Date: Thu, 11 Jun 2009 10:46:00 +0100
Robert Raschke wrote:
If I remember correctly, Lua optimises tail calls. In my experience,
using tail calls for state transitions is way easier to understand and
code than using goto's. But YMMV, I guess.
Tail calls don't let you easily share state using local variables ---
you either have to pass all your state in using parameters, or else put
the whole thing inside a bigger function and use upvalues. Either way,
it's significantly more heavyweight. Still fast (I posted some
benchmarks a little while ago), but considerably less so than a simple
jump from one bytecode location to another.
Or is your problem, that you've already got lots of machine generated
goto-state machines that you'd like to "translate" to Lua?
This is my major use case, yes, but it'd also be useful in other places.
Consider this --- most languages provide some sanitised goto to handle
doing this sort of thing:
while a do
while b do
while c do
while d do
if abort() then