Liste des Groupes | Revenir à cl forth |
Gerry Jackson <do-not-use@swldwa.uk> writes::) Well if you've never encountered this in (how many years has GForth been going - 25/30?) it's haardly worth bothering. At least it make someone think something strange is going on.Use of a wordlist, whose wid is held in an immediate constant, enablesIt means that Gforth will have to improve its SEE in order to point
easy linkage between states at compile time, eg a typical state action
in outline is:
>
:noname <action>
if state-x [ >order ] next-state [ previous ]
else state-y [ >order ] next-state [ previous ]
; this-state >order to next-state previous
out the differences between the different NEXT-STATEs. Currently I get:
/2 >order ok
next-state xt-see
noname :
dup @ #1 and
IF next-state
ELSE next-state
THEN ; ok
THe same applies to your example. Most FSM implementations have a transition table and/or a state diagram.Disadvantages are:That's definitely the case here.
- the Forth code doesn't give much idea of the overall operation of the
FSM (probably true for FSMs in general)
IIRC for Michael Gassanenko it was aThat's correct. I said it was a simple example of an FSM to demonstrate the principle the FSM
demonstration of filtering and backtracking,
but it's unclear to meThe transition table for my example is:
how that transfers to FSMs.
Anyway, let's look at the core:You know more about effects of an instruction cache than me bu wouldn't a short loop like that be likely to fit in a cache line?
: run-fsm ( ad xt -- ) begin dup while execute repeat 2drop ;This means that every state has to return to this loop to dispatch the
next one. Now Gforth (development) has EXECUTE-EXIT, which allows
tail-calling the next state for better efficiency.
I have worked out an example:Got to go but I'll return to this and look at your example in more detail later today hopefully.
https://www.complang.tuwien.ac.at/forth/programs/fsm-ae.4th
- anton--
Les messages affichés proviennent d'usenet.