Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aBPMr-0005sm-7M for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Dec 2015 16:00:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aBPMq-0007SU-QG for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Dec 2015 16:00:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aBPMq-0007RY-2u for pgsql-bugs@postgresql.org; Tue, 22 Dec 2015 16:00:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aBPMn-0008Be-9G for pgsql-bugs@postgresql.org; Tue, 22 Dec 2015 16:00:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id tBMG0lvm014108; Tue, 22 Dec 2015 11:00:47 -0500 From: Tom Lane To: henrik.pauli@uhusystems.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13829: Exponentiation operator is left-associative In-reply-to: <20151222140213.2675.849@wrigleys.postgresql.org> References: <20151222140213.2675.849@wrigleys.postgresql.org> Comments: In-reply-to henrik.pauli@uhusystems.com message dated "Tue, 22 Dec 2015 14:02:13 +0000" Date: Tue, 22 Dec 2015 11:00:47 -0500 Message-ID: <14107.1450800047@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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