407 views
in Getting started by

Hello Everyone. 

I have a little question abuot the Chora Language : does it use Lazy Evaluation?
For example, in a code snippet like the following :

var bool A = false;
if(A && foo() )
{
  ... something something ...
}

will foo() be called?

1 Answer

0 votes
by

Hello,

in this case (with variable A being false) the expression foo() right to the && operator is not evaluated. The method is thus not invoked. The logical operators && and || stop the evaluation as soon as the result of the expression is determined. In this case the value false in operand A affects the entire expression to return false.

I hope it helps you further.

Best regards

Paul Banach

by
Thanks for the clear and speedy answer!

Best Regards
Dario.
by

It is important to add, that the evaluation is performed from left to right. That means in case of ( foo() && A ), the method foo() is invoked even if A is false.

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...