discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

avoiding invalid operations with boolean expression evalution order?

R
richalt2
Fri, Aug 23, 2019 6:16 PM

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/

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/
NH
nop head
Fri, Aug 23, 2019 7:52 PM

Yes the normal shortcut logic applies like in C.

On Fri, 23 Aug 2019 at 19:13, richalt2 via Discuss <
discuss@lists.openscad.org> 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes the normal shortcut logic applies like in C. On Fri, 23 Aug 2019 at 19:13, richalt2 via Discuss < discuss@lists.openscad.org> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >