SQLite Forum

operator precedence docs missing, suggested clarifications below
Login
> <code>You could change it to something like this:

> SQLite understands the following operators, in order from highest to lowest precedence:

> ~ - + (the common unary operators)
COLLATE
||
*    /    %
+    -
<<   >>   &    |
<    <=   >    >=
=    ==   !=   <>   IS   IS NOT   IN   LIKE   GLOB   MATCH   REGEXP  BETWEEN
NOT
AND   
OR

>The unary prefix operators are these:

> -    +    ~    NOT

> The remaining operators are binary except for BETWEEN which is ternary.
</code>

(Sorry for the extra vertical spacing. Quoting and \<code/\> mix poorly.)

I think that you have stripped the apparent binariness from most of the operators for those who do not read down to that final note. (And I would pick a bone with "\[t\]he remaining operators", which does not clearly apply only to the just mentioned unary prefix operators. As a separate paragraph, it has an referent ambiguity.)

From this discussion, I have come to believe that Section 6 on BETWEEN is out of place. It's emphasis on precedence, and the fact that precedence is wrapped up by the end of Section 2 except for BETWEEN ... AND, make me think its precedence should be mentioned in Section 2 with its semantics addressed there, like the treatment that COLLATE gets.

I will ponder how to get BETWEEN mentioned with other equality-like operators without introducing confusion or distraction for that majority of readers (at any one reading) who want to quickly confirm or learn of less odd operator precedence. I think that latter deserves more weight than you are giving it in favor of the more abstract unification.