boolean expression evaluation

Discuss the Firewing language

boolean expression evaluation

Postby Jerry Messina » Wed Feb 27, 2013 9:12 am

I noticed that there doesn't seem to be much difference in operation between AND/ANDALSO and OR/ORELSE.

They all seem to perform short-circuit expression evaluation (which is perfectly fine with me... not sure why you'd want it otherwise).
Not having much VB experience, I just thought I'd check to see if that's intended.
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: boolean expression evaluation

Postby David John Barker » Wed Feb 27, 2013 11:43 am

"AndAlso" would normally have short-circuit evaluation but "And" does not. Personally I think that is back to front, as most programmers are familiar with "And", "Or" and use those syntactic elements. So, to answer your question, there is no difference between "And", "AndAlso" etc in terms of underlying code. If you did want to evaluate the right hand side of an expression, even if the left hand side returned false (and you would probably only want to do that if making a function call that changes somethings state) then you would need to re-arrange your code a little.

However, as you have pointed out, there is generally very little point in not having short circuit evaluation.
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest

x