[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: function with program counter
- From: Philipp Kraus <philipp.kraus@...>
- Date: Sun, 15 Sep 2013 07:42:04 +0200
On 2013-09-15 00:29:41 +0000, Tim Hill said:
On Sep 14, 2013, at 1:26 PM, Philipp Kraus
I would like to use a list structure for calling Lua function. So some
I have got a function e.g.
do first call
do some print
do second call
do some print again
I have got also a "program counter" which is started by 1. On 1 its
should run "do first call" on 2 "do some print" and so on.
I would like to use a Lua function, but I would like to run this
function step-by-step. I can use a if construct to check the current
"program counter value" and run the correct command, but this is not very nice.
Did you have an idea for this problem?
I think what you are really talking about is a state machine, which is
often handled by a switch statement. Since Lua lacks these, you end up
resorting to a bunch of "if" statements doing one-by-one checks of your
program counter, as you note.
Yes you're right, I'm thinking about a state-machine, each "function
call" must be atomic, but a function call can be run many other
The idea is, in which way can I do this nice in Lua and IMHO Andrew
Starks has got a greate idea