Short-circuit in 4GL?

OpenEdge short-circuits as this program demonstrates:

def var i1 as int no-undo.
def var i2 as int no-undo.

function f1 returns logical.
i1 = i1 + 1. return yes.
end.

function f2 returns logical.
i2 = i2 + 1. return yes.
end.

if f1() or f2() then message i1 i2 view-as alert-box. /*1 0*/

assign i1 = 0 i2 = 0.
if f1() and f2() then message i1 i2 view-as alert-box. /*1 1*/

----- Original Message -----
From: "jckinneman" <jckinneman@...>
To: <vantage@yahoogroups.com>
Sent: Wednesday, July 03, 2013 8:12 AM
Subject: [Vantage] Re: short-circuit in 4GL ?


I don't know if we can make that assumption since Progress's documentation doesn't appear to explicitly indicate it does short circuiting.

Jim Kinneman
Encompass Solutions, Inc

--- In vantage@yahoogroups.com, "Vic Drecchio" <vic.drecchio@...> wrote:
>
> In your example, using OR operators will definitely short circuit the
> statement.
>
>
>
> Using ORs will cause this. When the first condition is evaluated and if
> [varA = False], then the rest of the expression is not evaluated; it doesn't
> care about varB or varC's values. It's complete because everything else is
> "OR".
>
>
>
> If [varA = True], then it will continue and evaluate varB. If [varB =
> False], then varC is never evaluated because the statement's result has
> already been determined.
>
>
>
> Operators dictate the short circuiting. No short circuiting occurs when
> using ANDs inside the statement or expression.
>
>
>
> Short circuiting somewhat implies that the system is doing something wrong
> and it's not.. That's just the way it should work, right? Or am I missing
> something?
>
>
>
> Good little brain teaser for the last day of the week!
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of
> Bill Jackson
> Sent: Wednesday, July 03, 2013 8:22 AM
> To: vantage@yahoogroups.com
> Subject: [Vantage] short-circuit in 4GL ?
>
>
>
>
>
> Does Progress 4gl have the 'short-circuit' behavior like some other
> languages, in a multiple condition 'If' statement?
>
> ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:
>
> //stuff
>
> end.
> Else do:
>
> //other stuff
>
> End.
>
> 'short-circuit' being: As soon as one condition is met. then do //stuff
>
> We're looking to minimize decision making in a BPM directive.
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> [Non-text portions of this message have been removed]
>




------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links





-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3345 / Virus Database: 3204/6460 - Release Date: 07/03/13


[Non-text portions of this message have been removed]
Does Progress 4gl have the 'short-circuit' behavior like some other languages, in a multiple condition 'If' statement?

ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:

//stuff

end.
Else do:

//other stuff

End.

'short-circuit' being: As soon as one condition is met. then do //stuff


We're looking to minimize decision making in a BPM directive.

[Non-text portions of this message have been removed]
I searched through the reference and could not find anything regarding
short circuit.. I guess testing it would be the best way


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*


On Wed, Jul 3, 2013 at 8:21 AM, Bill Jackson <fujijapman@...> wrote:

> **
>
>
> Does Progress 4gl have the 'short-circuit' behavior like some other
> languages, in a multiple condition 'If' statement?
>
> ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:
>
> //stuff
>
> end.
> Else do:
>
> //other stuff
>
> End.
>
> 'short-circuit' being: As soon as one condition is met. then do //stuff
>
> We're looking to minimize decision making in a BPM directive.
>
> [Non-text portions of this message have been removed]
>
>
>


[Non-text portions of this message have been removed]
Opinion: I wouldn't worry about or expect much improvement if progress did or did not have short circuit. The only advantage other than a possible minor performance gain is when the first test is if something actually exists or isn't null and the subsequent tests would blow up if so. Something I use frequently in C#. If that is the case than as Jose mentions a test would be needed. For example if you wanted to combine a test to see if a handle was valid and then test something connected to the handle.

Otherwise my recommendation is focus more on writing code for maintainability and clarity. If combining IF statements does that do it, if separate IF statements make the code clearer do it. Instead of IF you might consider CASE statement which many times helps me see a pattern that allows me to condense my logic.

I've found that if code is readable and thus maintainable any tweaks for performance usually become very clear.

Jim Kinneman
Encompass Solutions, Inc.

--- In vantage@yahoogroups.com, Bill Jackson <fujijapman@...> wrote:
>
> Does Progress 4gl have the 'short-circuit' behavior like some other languages, in a multiple condition 'If' statement?
>
> ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:
>
> //stuff
>
> end.
> Else do:
>
> //other stuff
>
> End.
>
> 'short-circuit' being: As soon as one condition is met. then do //stuff
>
>
> We're looking to minimize decision making in a BPM directive.
>
> [Non-text portions of this message have been removed]
>
In your example, using OR operators will definitely short circuit the
statement.



Using ORs will cause this. When the first condition is evaluated and if
[varA = False], then the rest of the expression is not evaluated; it doesn't
care about varB or varC's values. It's complete because everything else is
"OR".



If [varA = True], then it will continue and evaluate varB. If [varB =
False], then varC is never evaluated because the statement's result has
already been determined.



Operators dictate the short circuiting. No short circuiting occurs when
using ANDs inside the statement or expression.



Short circuiting somewhat implies that the system is doing something wrong
and it's not.. That's just the way it should work, right? Or am I missing
something?



Good little brain teaser for the last day of the week!



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of
Bill Jackson
Sent: Wednesday, July 03, 2013 8:22 AM
To: vantage@yahoogroups.com
Subject: [Vantage] short-circuit in 4GL ?





Does Progress 4gl have the 'short-circuit' behavior like some other
languages, in a multiple condition 'If' statement?

ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:

//stuff

end.
Else do:

//other stuff

End.

'short-circuit' being: As soon as one condition is met. then do //stuff

We're looking to minimize decision making in a BPM directive.

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]
I don't know if we can make that assumption since Progress's documentation doesn't appear to explicitly indicate it does short circuiting.

Jim Kinneman
Encompass Solutions, Inc

--- In vantage@yahoogroups.com, "Vic Drecchio" <vic.drecchio@...> wrote:
>
> In your example, using OR operators will definitely short circuit the
> statement.
>
>
>
> Using ORs will cause this. When the first condition is evaluated and if
> [varA = False], then the rest of the expression is not evaluated; it doesn't
> care about varB or varC's values. It's complete because everything else is
> "OR".
>
>
>
> If [varA = True], then it will continue and evaluate varB. If [varB =
> False], then varC is never evaluated because the statement's result has
> already been determined.
>
>
>
> Operators dictate the short circuiting. No short circuiting occurs when
> using ANDs inside the statement or expression.
>
>
>
> Short circuiting somewhat implies that the system is doing something wrong
> and it's not.. That's just the way it should work, right? Or am I missing
> something?
>
>
>
> Good little brain teaser for the last day of the week!
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of
> Bill Jackson
> Sent: Wednesday, July 03, 2013 8:22 AM
> To: vantage@yahoogroups.com
> Subject: [Vantage] short-circuit in 4GL ?
>
>
>
>
>
> Does Progress 4gl have the 'short-circuit' behavior like some other
> languages, in a multiple condition 'If' statement?
>
> ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:
>
> //stuff
>
> end.
> Else do:
>
> //other stuff
>
> End.
>
> 'short-circuit' being: As soon as one condition is met. then do //stuff
>
> We're looking to minimize decision making in a BPM directive.
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> [Non-text portions of this message have been removed]
>