# Logic: is Bubble's way of using AND and OR flawed? Can we have parentheses please?

Hello everybody,

I got the following problem when implementing complicated conditions and using the AND and OR statements. In most programming languages the AND operator is priorized before the OR operator, so the following statement will evaluate the same, no matter whether the parentheses are set or not:

(Condition_1 AND Condition_2) OR (Condition_3 AND Condition_4)

In bubble however I don’t find this to be true, see the example attached below. I defined four checkboxes, and wrote a condition on a shape such that it becomes green when either the first two boxes are checked, or the second two boxes are checked. The shape however becomes green only when the last two boxes are checked and will ignore the first part of the conditional statement.

Can someone help please in explaining why this is so, and how the above intention should be implemented WITHOUT the need to define N separate conditions (hint: the condition statement should be easy to copy-paste).

Thanks in advance ! Regards … O.

2 Likes

Bubble evaluates Left to Right. That is why it doesn’t work.

If this is too much complexity …

Then convert the two checkboxes into a reusable element.

Then run a couple of conditions that set a custom state.

Only have to set that up once.

Then repeat the element as often as you like and just check for the custom state.

1 Like

Hi Nigel,

thank you for the alternatives. But yes, it is unfortunately way too much of an effort if there are 8 or so condition pairs, and all of them are distributed all over the page with no possibility to do an intelligent subgrouping.

Why does bubble evaluate boolean logic from left to right?

I know of no other programming language doing this. Operator precedence follows international norms and is aimed at efficient coding, it is difficult to see why bubble would want to deviate. This is such a productivity killer. Is there a way to fix the interpreter? For instance by allowing for parentheses?

Thanks for your assessment, many regards … O.

3 Likes

Smalltalk springs to mind.

There are probably several other ways to do what you want to do. May be worth looking for alternatives (I came up with two in as many minutes) rather than doing the computer sciencey thing.

Humans tend to read left to right. Bubble is for humans. And isn’t a programming language.

I suspect brackets will arrive one day, and it will certainly make things easier.

So yes, you are almost certainly right from a strict perspective. It is an odd way of doing it. But that is the way it works until we get brackets.

1 Like

Hi Nigel,

I understand your point, but what a disappointment. Yes, humans read from left to to right, but sometimes - particularly like right here - there are indentations in the textflow which need to be interpreted by putting together what belongs together. If someone is told that he gets half of the gain if he goes validate a winning lottery ticket and do it before noon, or when he goes pick up a coin and put it in his wallet, will he really want to neglect the first part of this information, just because we are reading from left to right ?

Thanks for your elaborated response. Do you know where to find the information in what release and at what point in time the parentheses will be implemented?

Regards … O.

1 Like

Yes, it is here.

This topic was automatically closed after 70 days. New replies are no longer allowed.