[Top][All Lists]

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

Re: [Chicken-users] State machine using call/cc

From: felix winkelmann
Subject: Re: [Chicken-users] State machine using call/cc
Date: Wed, 8 Dec 2004 12:21:17 +0100

On Wed, 8 Dec 2004 09:22:58 +0000, Joel Reymont <address@hidden> wrote:
> I'm looking to have a single dispatch function that is called from C/C++
> and is passed a string and should return a string to be sent out.
> Dispatch would call an appropriate state machine instance (continuation?)
> with an event deserialized from the passed string and the state machine
> would advance to the next state internally.
> I'm have no problem with the dispatch function yet as I have not gotten
> to it. I just can't figure out how to do the state machine with call/cc
> and have it advance from state to state upon event _as well as_ return
> the result of the state's action as a string.

So, if I understand you correctly, each "state" is a computation,
being suspended at its current point in a sequence of operation,
So say your logic looks like this:

(define (play-game game) this... that...
  (next-state game) something else...

Then (for example) the next-state procedure would save the
current game state somewhere, together with the current
continuation and return to the dispatcher:

(define (next-state game)
    (lambda (k)

      (hash-table-set! *global-state-table* (game-id game)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]