Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline mkraska  
#1 Posted : 12 January 2013 17:46:35(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1126 time(s) in 723 post(s)
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

a:1|0 and a:1|0

This is not what I expected. Instead, I have to use braces to make sure the boolean operation is evaluated before the assignment operation:

aSad1|0) and aSad1|0) 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

0<x&x<1 by just typing 0<x&x<1

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

Edited by user 23 March 2014 17:57:03(UTC)  | Reason: Not specified

File Attachment(s):
boolean.sm (17kb) downloaded 18 time(s).
mkraska attached the following image(s):
boolean.png
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 31/01/2013(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline mkraska  
#2 Posted : 04 May 2013 00:56:47(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1126 time(s) in 723 post(s)
Originally Posted by: mkraska Go to Quoted Post

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.
mkraska attached the following image(s):
boolshit.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.