1

I have a FO-program that throws an error when it approaches this line:

.continue ERR1 ? F|defined(M|yhnum) & M|yhnum > 10

The error is

M|yhnum: not found

Why does this happen? I thought it wouldn't happen if I checked if the variable is defined before accessing it, but it doesn't seem like it worked

aphex
  • 3,372
  • 2
  • 28
  • 56
Breeze
  • 2,010
  • 2
  • 32
  • 43

1 Answers1

2

The problem here is, that FO doesn't use short circuit evaluation. This means that it will always check if M|yhnum is bigger than 10, even if it is not defined. Obviously, this will fail if it is not defined.

From the documentation:

This means that a Boolean expression will be completely evaluated even if the final result can already be seen from the intermediate result. This is significant in connection with defined().

Use F|condexpr to manually achieve short circuit evaluation

.continue ERR1 ? F|condexpr(F|defined(M|yhnum), M|yhnum > 10, G|false)
Breeze
  • 2,010
  • 2
  • 32
  • 43