Hi Tom, > Le 19 mai 2019 à 20:27, Tom Lane <t...@sss.pgh.pa.us> a écrit : > > Akim Demaille <a...@lrde.epita.fr> writes: >> In the following two proposed patches, I remove directives that are >> completely useless. > > I'm far from convinced that the proposed changes in gram.y are a good > idea. Both [] and . (field selection) *are* left-associative in a > meaningful sense, so even if this change happens not to affect what > Bison does, I think the declarations are good documentation.
I don't dispute the overall behavior of the grammar as a whole, I'm only referring to these directives. In my experience, leaving useless associativity and precedence directives can be misleading (since these directives have no impact, you could put them anywhere: their contribution is not checked in any way) or even dangerous (some day, some change introduces unexpected shift-reduce conflicts that someone should have studied, but because of "stray" directives, they are "fixed" in some uncontrolled way). > Would > you have us also change the user documentation at > https://www.postgresql.org/docs/devel/sql-syntax-lexical.html#SQL-PRECEDENCE > ? No, of course not! That you define the arithmetics with an unambiguous grammar (expr/term/fact and no associativity/precedence directive) or with an ambiguous grammar (expr and associativity/precedence directives) still results in the same behavior: the usual behavior of these operators. And the documentation should document that, of course. It is for the same reasons that I would recommend not using associativity directives (%left, %right, %nonassoc) where associativity plays no role: %precedence is made for this. But it was introduced in Bison 2.7.1 (2013-04-15), and I don't know if requiring it is acceptable to PostgreSQL. Cheers!