1 страниц (2 вхождений)
Hard to create the expression a:=b|c - BTS issue SS-55 - Сообщения
#1 Опубликовано: 12.01.2013 10:46:35
Hi,
when trying to generate a table of function values for boolean operators I found the input behaviour of OR, AND and XOR quite confusing.
typing a:1|0 or a:1&0 I get
[MATH]a:1|0[/MATH] and [MATH]a:1|0[/MATH]
This is not what I expected. Instead, I have to use braces to make sure the boolean operation is evaluated before the assignment operation:
[MATH]a
1|0)[/MATH] and [MATH]a
1|0)[/MATH] by typing a: (1|0
This implies that the assignment operator has higher priority than boolean AND, OR and XOR, which is odd. I guess that the design intent is that AND, OR and XOR take lower priority than numeric comparison operations. This facilitates writing conditionals like
[MATH]0
However, precedence over assignment is confusing. What sensible boolean result is the assignment operator supposed to provide?
Thus I propose to re-adjust the operator precedence, such that there is no need to bracket the rhs of an assignment.
Edit: Additionally, the equal and not-equal operators silently adopt the same lower precedence like the mentioned boolean operators, but do not enforce brackets around their operators. This leads to wrong results.
Martin Kraska

when trying to generate a table of function values for boolean operators I found the input behaviour of OR, AND and XOR quite confusing.
typing a:1|0 or a:1&0 I get
[MATH]a:1|0[/MATH] and [MATH]a:1|0[/MATH]
This is not what I expected. Instead, I have to use braces to make sure the boolean operation is evaluated before the assignment operation:
[MATH]a


This implies that the assignment operator has higher priority than boolean AND, OR and XOR, which is odd. I guess that the design intent is that AND, OR and XOR take lower priority than numeric comparison operations. This facilitates writing conditionals like
[MATH]0
However, precedence over assignment is confusing. What sensible boolean result is the assignment operator supposed to provide?
Thus I propose to re-adjust the operator precedence, such that there is no need to bracket the rhs of an assignment.
Edit: Additionally, the equal and not-equal operators silently adopt the same lower precedence like the mentioned boolean operators, but do not enforce brackets around their operators. This leads to wrong results.
Martin Kraska
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
Davide Carpi 31.01.2013 12:51:00
#2 Опубликовано: 03.05.2013 17:56:47
Wrote
Edit: Additionally, the equal and not-equal operators silently adopt the same lower precedence like the mentioned boolean operators, but do not enforce brackets around their operators. This leads to wrong results.
The issues remain open in 0.96, in particular the cited issue is dangerous.
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 страниц (2 вхождений)
-
Новые сообщения
-
Нет новых сообщений