
On Jun 22, 2006, at 4:08 PM, Jim Fulton wrote: ...
A simple state machine is used to implement this:
state_machine = { # =>< '<' : '--T', '<=': 'T-T', '>' : 'F+F', '>=': 'T+F', '==': 'T..', '!=': 'F++', }
cmp() is used to determine whether the version is =, >, or < than the condition's version, and the appropriate row and column is pulled from the above table. "T" means "sure accept", "F" means "sure reject", "+" means "tentative accept", and "-" means "tentative reject". ("." means "don't care".) The state machine simply compares versions until its sure or there are no more to compare.
I don't understand the meaning of the values in the dictionary above. Do the character positions reflect states somehow?
It's a truth table: the rows are condition operators, and the columns are cmp() results. It is simply a transcription of the rules about points and bounds that I spelled out verbally, reduced to a table lookup on the condition and the comparison results.
OK, than makes sense. So, with the requirement: >1, <3, >5, <7 So let's see, with 4, we get +-F and we reject it. OK, that makes sense.
The state machine helps a lot. My question is now answered.
I think that the fact that you need to understand a non-trivial algorithm with a state machine to understand how non-trivial specifications are interpreted is a problem. Maybe it's enough to tell people "don't use complex specifications", but maybe it would be better to use a simpler system.
I also think that the complete algorithm, including the state machine needs to be documented clearly. Your original paragraph really isn't adequate. Maybe, you should document simple cases and refer to the full complex model for non-trivial cases. Jim -- Jim Fulton mailto:jim@zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org