Re: BUG #13829: Exponentiation operator is left-associative

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #13829: Exponentiation operator is left-associative
Дата
Msg-id 14107.1450800047@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #13829: Exponentiation operator is left-associative  (henrik.pauli@uhusystems.com)
Ответы Re: BUG #13829: Exponentiation operator is left-associative  (Henrik Pauli <henrik.pauli@uhusystems.com>)
Список pgsql-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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: BUG #13824: EXISTS sometimes uses seq scan instead of index
Следующее
От: Kevin Grittner
Дата:
Сообщение: Re: Fwd: Cannot log in as newly created user EXTRA INFO