On 3/17/2012 9:31 AM, Antti J Ylikoski wrote:
On 17.3.2012 17:47, Roy Smith wrote:
In article<gR09r.22645$i33.16...@uutiset.elisa.fi>,
Antti J Ylikoski<antti.yliko...@tkk.fi> wrote:
I came across the problem, which would be the clearest way to program
such algorithms with a programming language such as Python, which has
no GOTO statement.
Oh, my, I can't even begin to get my head around all the nested
conditionals. And that for a nearly trivial machine with only 5 states.
Down this path lies madness.
Right. Few programs should be written as state machines.
As a means of rewriting Knuth's algorithms, it's inappropriate.
Some should. LALR(1) parsers, such as what YACC and Bison
generate, are state machines. They're huge collections of nested
switch statements.
Python doesn't have a "switch" or "case" statement. Which is
surprising, for a language that loves dictionary lookups.
You can create a dict full of function names and lambdas, but
it's clunky looking.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list