Author Topic: OR and AND conditions bug  (Read 979 times)

Offline ratchet

  • Newbie
  • *
  • Posts: 11
  • Rep: 0
    • View Profile
OR and AND conditions bug
« on: April 14, 2010, 11:52:20 am »
Example code:
[scar]program test;
function test(): boolean;
begin
     writeln('Do not go here');
     result:= true;
end;
begin
     if (true or test()) then writeln('true or true');
     if (false and test()) then writeln('false and true');
end.[/scar]

The test() is executed in both cases, although the IF branches correctly. The condition checking should no longer be necessary after the first true OR and false AND.

Implementing this change will also optimise the performance as long chains of conditionals will no longer have to all be checked before branching.

Optimizations within the code by having the most common tested first will also work.

Freddy1990.com

OR and AND conditions bug
« on: April 14, 2010, 11:52:20 am »

Offline nielsie95

  • Administrator
  • *****
  • Posts: 465
  • Rep: 6
    • View Profile
Re: OR and AND conditions bug
« Reply #1 on: April 14, 2010, 01:46:42 pm »
Short circuit boolean evaluation is currently not supported by SCAR. You're right about that it will be faster and easier, but it's not a bug ;)
A winner never quits, because a quitter never wins.
Heroes get remembered, legends never die.
Use what talents you possess: the woods would be very silent if no birds sang there except those that sang best.

Freddy1990.com

Re: OR and AND conditions bug
« Reply #1 on: April 14, 2010, 01:46:42 pm »

Offline ratchet

  • Newbie
  • *
  • Posts: 11
  • Rep: 0
    • View Profile
Re: OR and AND conditions bug
« Reply #2 on: April 14, 2010, 05:43:00 pm »
Is that a way of saying that this won't be fixed?

Offline Freddy

  • Owner
  • *****
  • Posts: 2614
  • Rep: 19
    • MSN Messenger - freddy1990@gmail.com
    • AOL Instant Messenger - Freddy199O
    • View Profile
    • Email
Re: OR and AND conditions bug
« Reply #3 on: April 15, 2010, 04:26:30 am »
Is that a way of saying that this won't be fixed?
Pretty much... You have to contact the author of the script engine SCAR uses to request this feature... But the author has expressed that he does not wish to add many more new features because some features are nearly impossible to add due to the way the engine is constructed... http://www.remobjects.com/ps.aspx

Offline ratchet

  • Newbie
  • *
  • Posts: 11
  • Rep: 0
    • View Profile
Re: OR and AND conditions bug
« Reply #4 on: April 16, 2010, 03:06:53 am »
I had a peek at the Pascal script for Delphi source, and it looks like it is already there.

It looks like it is set as a property of the compiler class, I'm pretty sure your dephi is better than mine but hopefull this helps to get it going.

In file uPSCompiler.pas (line: 1181):
Code: [Select]
    property BooleanShortCircuit: Boolean read FBooleanShortCircuit write FBooleanShortCircuit;

Freddy1990.com

Re: OR and AND conditions bug
« Reply #4 on: April 16, 2010, 03:06:53 am »

Offline Freddy

  • Owner
  • *****
  • Posts: 2614
  • Rep: 19
    • MSN Messenger - freddy1990@gmail.com
    • AOL Instant Messenger - Freddy199O
    • View Profile
    • Email
Re: OR and AND conditions bug
« Reply #5 on: April 17, 2010, 05:26:21 pm »
I had a peek at the Pascal script for Delphi source, and it looks like it is already there.

It looks like it is set as a property of the compiler class, I'm pretty sure your dephi is better than mine but hopefull this helps to get it going.

In file uPSCompiler.pas (line: 1181):
Code: [Select]
    property BooleanShortCircuit: Boolean read FBooleanShortCircuit write FBooleanShortCircuit;
Wtf, it's in there and not enabled by default? It shouldn't even be an option, it should be in there by default, that's just retarded... Well, I'll enable it in the next SCAR release...

Fixed for 3.25
« Last Edit: June 13, 2010, 05:49:40 am by Freddy1990 »

Freddy1990.com

Re: OR and AND conditions bug
« Reply #5 on: April 17, 2010, 05:26:21 pm »