From: Tom Lane <tgl@sss.pgh.pa.us>
To: henrik.pauli@uhusystems.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13829: Exponentiation operator is left-associative
Date: Tue, 22 Dec 2015 11:00:47 -0500
Message-ID: <14107.1450800047@sss.pgh.pa.us> (raw)
In-Reply-To: <20151222140213.2675.849@wrigleys.postgresql.org>
References: <20151222140213.2675.849@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
henrik.pauli@uhusystems.com writes:
> The convention with exponentation is the following (according to Wikipedia):
> "Without parentheses to modify the order of calculation, by convention the
> order is top-down, not bottom-up" -- in programming terms, it means that
> exponentation is by default right-associative.
> ...
> However, PostgreSQL -- as indeed mentioned in the docs -- considers the
> paren-less version more like the one where the left side is parenthesised:
Yeah. I can't see us changing this. Aside from backwards-compatibility
considerations, "^" is not so thoroughly identified with exponentiation
that no-one would ever make a custom operator named "^" that did something
else. Since operator precedence and associativity are determined solely
by the operator name, right-to-left associativity would have to apply to
such custom operators too, which would be mighty surprising if their
semantics were something else.
However, pointing the issue out somewhere near Table 9-2. Mathematical
Operators seems reasonable. The minimum change would just be to call it
out in the table entry itself:
Operator Description Example Result
...
^ exponentiation (associates left to right) 2.0 ^ 3.0 8
Do you think that's sufficient?
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, henrik.pauli@uhusystems.com
Subject: Re: BUG #13829: Exponentiation operator is left-associative
In-Reply-To: <14107.1450800047@sss.pgh.pa.us>
References: <20151222140213.2675.849@wrigleys.postgresql.org> <14107.1450800047@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox