On 29 Jun 2008, at 18:41, Matt Neuburg wrote:
In practice a numeric score is calculated for a scope selector match.
The score will be 1.0 for full overlap between scope and scope selector, 0.0 for no overlap (i.e. empty scope selector), and below zero for “negative overlap” (i.e. the scope selector has elements not part of the scope). The values between 0.0 and 1.0 are calculated corresponding to the rules given in 13.5 (done by effectively converting each fragment of the scope to a fraction and have all those numbers form a harmonic serie and then add the fractions that correspond to fragments matched by the scope selector).
With a numeric score for each scope selector match it is trivial to calculate the score of a compound expression. E.g.: score(a | b) = max(score(a), score(b)).
And what about score(a & b)? You say "trivial" but it is not at all obvious to me what scoring strategy is right to adopt here.
And I repeat, what about rule 3 in section 13.5? Suppose
Forget about 13.5 and re-read my part about numeric scores. One number is calculated, it is not an iterative algorithm. 13.5 is just describing the effect of how these numbers (ranks) are calculated, but in practice it is done as a simple optimization problem.
[...] But I do not see how to shorten
((string source) & ruby)
This will be: max(score(string source), score(ruby))
Assuming both scores are ≥ 0 (otherwise the result will be -1, i.e. not a match).