
At 03:20 PM 6/22/2006 -0400, Jim Fulton wrote:
The implementation scans from left to right until it's *sure* that the version is either accepted or rejected. Each condition is a point, a bound, or a point and a bound. If the version matches the "point" part of condition, it's an exact match and you are *sure* of an accept, unless it's a "!=", in which case you're *sure* it's a reject.
If the version falls below an upper bound (< or <=), you are also *sure* that it's accepted. If it is above an upper bound, it is *tentatively* rejected.
So given: >1, <3, >5, <7 You are sure that 4 is accepted?
Scanning left to right, >1 is a lower bound and 4 is above it, so that's a tentative accept. Next we see <3, and it is an upper bound, and we fall below it, so it is a sure accept at that point, and we stop scanning.
Given: <2, <5 Is 3 accepted or rejected?
<2, upper bound, 3 is above, tentative reject. <5, upper bound, 3 is below it, sure accept. (Intuitively -- at least for me -- <5 is paired with >-infinity here.)
If the version falls below a lower bound (> or >=), you are *sure* that it's rejected. If it is above a lower bound, it is *tentatively* accepted.
So given: >1, <3, >5, <7 You are sure that 2 is rejected?
1, lower bound, 3 is above, tentative accept. <3, upper bound, 2 is below, sure accept, scanning stops.
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.