From: | Akim Demaille <akim(at)lrde(dot)epita(dot)fr> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Remove useless associativity/precedence from parsers |
Date: | 2019-05-20 04:45:56 |
Message-ID: | 21B7EE24-19F5-4245-AFA6-B1F51AA5F6DD@lrde.epita.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Tom,
> Le 19 mai 2019 à 20:27, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> a écrit :
>
> Akim Demaille <akim(at)lrde(dot)epita(dot)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!
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-05-20 04:46:25 | Re: Parallel Append subplan order instability on aye-aye |
Previous Message | Amit Langote | 2019-05-20 04:45:10 | Re: behaviour change - default_tablesapce + partition table |