Faulty And/Or Processing

Post bugreports for the Windows version here
#NULL
Addict
Addict
Posts: 1338
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Faulty And/Or Processing

Post by #NULL »

i didn't know the PB short-circuit was actually documented :)

i usally even tend to write

Code: Select all

If (Not a) And b
though i know that Not has higher presedence than And.
i find with the braces you qickly get some geometry/nesting visualized, just as indentation does. you wouldn't omit the indentation, even not for three lines of code, though its actually redundant.

but as i read, others perceive different, some say they get an expression quicker without braces.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Faulty And/Or Processing

Post by Dude »

DontTalkToMe wrote:Don't you realize what you are saying it's nonsense ?
Yeah, I misread the code example. :oops:
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: Faulty And/Or Processing

Post by DontTalkToMe »

@Dude, that's a relief :wink:

Since you removed everything I edited my message where I was barking at you :D
User avatar
Tenaja
Addict
Addict
Posts: 1816
Joined: Tue Nov 09, 2010 10:15 pm

Re: Faulty And/Or Processing

Post by Tenaja »

Keya wrote:its always been a habit of mine to uses brackets even where not needed, such as A = A + (B * C)
is this considered bad practice in those cases? or does it not really matter?
It is never bad practice to reduce ambiguity. It is always good practice to increase clarity.

The addition of parentheses (or brackets) only clarifies, and makes the code more portable. With the parens, you are not relying on the compiler and its precedence as much as you are relying on solid portable code. I would not say that omitting them is not bad, though.

The PowerBasic code at the top of this thread is the perfect example of this. It worked there, and someone hoped and/or assumed it would work with pb, and that was not the case. Had the parens been added in the first place, there would not be a reason for this thread.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: Faulty And/Or Processing

Post by DontTalkToMe »

Tenaja wrote: The PowerBasic code at the top of this thread is the perfect example of this. It worked there, and someone hoped and/or assumed it would work with pb,
I disagree with that. It does not work because the compiler it's bugged, not because it decided to follow a personal boolean logic we (and the rest of the world) need to learn.
Tenaja wrote: Had the parens been added in the first place, there would not be a reason for this thread.
The bug would not be known then, but actually was already known, and it will be discovered again.
User avatar
kenmo
Addict
Addict
Posts: 1897
Joined: Tue Dec 23, 2003 3:54 am

Re: Faulty And/Or Processing

Post by kenmo »

Code: Select all

True = #True
Debug Bool(  True And #True Or #False)
Debug Bool( #True And  True Or #False)
It's a bug. Parentheses can be used to work around it, but shouldn't be used to hide this bug for more years.
User avatar
Tenaja
Addict
Addict
Posts: 1816
Joined: Tue Nov 09, 2010 10:15 pm

Re: Faulty And/Or Processing

Post by Tenaja »

My statement was in response to asking if it is bad practice to use parens.

It is never bad practice. Bugs or not. Whether Fred and Freak decide the bugs are tolerable is a different topic.

Either way, it is still true that had the original author of Power code used parens, and carried them over to PB, it would not be a topic of discussion in this thread.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: Faulty And/Or Processing

Post by DontTalkToMe »

Tenaja wrote: Either way, it is still true that had the original author of Power code used parens, and carried them over to PB, it would not be a topic of discussion in this thread.
Absolutely, and luckily he didn't, so this thread exists, mirroring the previous ones but with some more flavor added.

My response instead was to you because I read some kind of reprimand directed to the OP because he dared to think that code would have worked here too. "someone hoped and/or assumed it would work with pb".
Because it was a legitimate assumption. We are talking about some ANDs and one OR. Maybe I read too much in it, but just to be on the safe side ... in case I did sorry to have misunderstood you.
ANDY ANDERSON
User
User
Posts: 62
Joined: Thu Aug 28, 2014 9:02 pm

Re: Faulty And/Or Processing

Post by ANDY ANDERSON »

I think that this thread has established that, relative to other languages that
we are familiar with, PureBasic is not processing the And/Or combination correctly.

If this is some maverick feature of PureBasic then it should be noted in the Help
text, otherwise, it must be considered a bug.

This anomaly was reported at least 7 years ago and has not been fixed to date. This
is disturbing because with out the correct processing of conditional clauses, a
computer is nothing more than a simple adding machine with memory.

If the PureBasic team responds to this, their comments are awaited with interest.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Faulty And/Or Processing

Post by Dude »

Thanks, DTTM. :)
User avatar
Blue
Enthusiast
Enthusiast
Posts: 733
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Faulty And/Or Processing

Post by Blue »

kenmo wrote:

Code: Select all

True = #True
Debug Bool(  True And #True Or #False)
Debug Bool( #True And  True Or #False)
@kenmo : I admire the brevity and clarity of your demonstration.
Just the essentials. It does not get better.

@ANDY ANDERSON : great summation !

When is that very basic bug finally going to be corrected ?
Last edited by Blue on Thu Jun 16, 2016 4:59 am, edited 1 time in total.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Thunder93
Addict
Addict
Posts: 1773
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Faulty And/Or Processing

Post by Thunder93 »

Blue wrote:
kenmo wrote:

Code: Select all

True = #True
Debug Bool(  True And #True Or #False)
Debug Bool( #True And  True Or #False)
@kenmo : I admire the brevity and clarity of your demonstration.
Just the essentials. It does not get better.

@ANDY ANDERSON : great summation !

When is that very basic bug finally going to be corrected ?
Well said..! by both! :)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Post Reply