Programming D. E. Knuth in Python with the Deterministic Finite Automaton construct

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Mar 17 21:54:10 EDT 2012


On Sat, 17 Mar 2012 17:28:38 -0600, Michael Torrie wrote:

> Thank you.  Your example makes more clear your assertion about "labels"
> and how really A1 and A5 were the only real labels in the example.
> Though I still do not really see why "states" is not a good equivalence
> for labels in this case.

Program labels are states.

You can treat every line of code as being invisibly labelled with the 
line number. (Or visibly, if you are using BASIC back in 1975.) Clearly 
"the interpreter is executing at line 42" is a state distinct from "the 
interpreter is executing line 23", but that state *alone* is not 
sufficient to know the overall state of the program.

Adding an explicit GOTO label does not change this.

But this refers to the state of the interpreter, not the state of the 
program being executed, and either way, is not a state in the sense of a 
finite state machine.


-- 
Steven



More information about the Python-list mailing list