GOTO (was Re: Appeal for python developers)
Heiko Wundram
modelnine at ceosg.de
Mon Mar 7 05:37:33 EST 2005
On Sunday 06 March 2005 14:26, Anthra Norell wrote:
> <snip long goto explanation>
Wow, I never thought I'd say this, but this certainly is an ingenious use of
goto... But, nevertheless, I don't think this is applicable to Python as a
way of justifying goto in the language, as your program doesn't have a split
between abstract state machine and real program anymore (which I think should
be there, as the abstract state machine is actually data, which controls
program flow).
The way I'd code it in Python is something like:
SETUP = object()
ELSE = object()
BREAK = object()
machine = {"WAITING FOR ACTION":
{customer_drops_coin:"COIN HAS BEEN DROPPED",
customer_selects_beverage:"ORDER RECEIVED",
customer_cancels_order:"ACCOUNT CLOSURE IS DUE"
ELSE:"WAITING FOR ACTION"},
"COIN HAS BEEN DROPPED":
{SETUP:identify_coin,
credit_account:"PAYMENT DUE IS UNKNOWN"},
"ORDER RECEIVED":
{...
Reading the state machine in the way presented above isn't any harder in my
taste than reading your state table, and you should easily be able to run the
machine from there...
--
--- Heiko.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050307/982db34f/attachment.sig>
More information about the Python-list
mailing list