A generic loop construct controlled by natural language...
Implementing detect in Python

by Magnus Lie Hetland




This is a simple preprocessor I have made which implements the detect control structure, invented by Arne Halaas in the early seventies (Halaas 1975). It has been adapted to the Python syntax, and (for now) the "events" are placed at the end of the "clean-up" blocks, because they cause immediate exit from the loop. In the future, I might fix this so that it will resemble the original more closely, with the event strings starting the clean-up blocks.

Hopefully, I will add some descriptions of the statement and its usage here, but for now, there is only the code...

partition.py is only an example. You can run it like this:

  $ dpython partition.py

... assuming that you put all the .py-files in your PYTHONPATH and dpython in your PATH, and change it to executable.

Note: You have to change the string "/store/bin/python" in dpython to the absolute path of your python executable. (For some reason I couldn't get sys.executable to return anything useful...)

Remember - this is a very early version. Don't expect much. :)



References

Halaas, A. (1975)
"Event-Driven Control Statements", BIT 15, pp. 229-275


[Main python page]


Copyright © Magnus Lie Hetland (mlh@idi.ntnu.no)
Last modified: Sun Mar 14 19:41:19 MET 1999