TomKrauss / pks-edit

A code editor originally implemented for Atari ST - now available as Windows 64 Bit application
Mozilla Public License 2.0
8 stars 2 forks source link

Evaluate logical Expressions in PKSMacroC using short-circuit Evaluation #6

Closed TomKrauss closed 2 years ago

TomKrauss commented 2 years ago

Expressions in PKSMacroC such as (a == 'x' && b == 'y') will always evaluate each sub-expression. This is in particular impractical when one tries to test an assumption in the 1st sub-expression necessary to evaluate the second expression such as in the following example:

if (size(array) > 10 && array[10] == 'x')...

Executing this code in PKSMacroC will cause a run-time error for arrays of size less then 10. To avoid the run-time error one must rearrange the expression to:

if (size(array) > 10) {
  if (array[10] == 'x')...

To make implementing PKSMacroC code easier and to have PKSMacroC be more compatible to C- / Java-like languages we should support short-circuit evaluation aka McCarthy evaluation.

TomKrauss commented 2 years ago

Implemented in v2.2.0