ink icon indicating copy to clipboard operation
ink copied to clipboard

Short-circuit Logical AND expressions

Open russellquinn opened this issue 2 years ago • 2 comments

I have an Ink function of the form:

=== function can_do_something()
    ~ return some_var == 0 && some_expensive_to_run_external_function() == true

some_expensive_to_run_external_function gets called every time, even when some_var == 0

Ideally, for performance, Ink would follow other languages where typical behavior is:

&& guarantees left-to-right evaluation: the second operand is not evaluated if the first operand is false.

russellquinn avatar Jan 28 '23 00:01 russellquinn