avoiding invalid operations with boolean expression evalution order?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

avoiding invalid operations with boolean expression evalution order?

discuss
Do boolean expression have an evaluation order, and subexpresions which are
guaranteed to *not* be evaluated?   So what is the correct coding expression
for:
  conditionA && conditionB && function_valid_only_if_A_andB()

Can I expect such a boolean to *not* call the function if conditionA or B is
false?
Must such be coded with if, or other method to insure the function is not
called unless proper?

Thanks!




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: avoiding invalid operations with boolean expression evalution order?

nophead
Yes the normal shortcut logic applies like in C.

On Fri, 23 Aug 2019 at 19:13, richalt2 via Discuss <[hidden email]> wrote:
Do boolean expression have an evaluation order, and subexpresions which are
guaranteed to *not* be evaluated?   So what is the correct coding expression
for:
  conditionA && conditionB && function_valid_only_if_A_andB()

Can I expect such a boolean to *not* call the function if conditionA or B is
false?
Must such be coded with if, or other method to insure the function is not
called unless proper?

Thanks!




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org