Am 15.01.2021 um 12:43 schrieb Riccardo (Jack) Lucchetti:
On Fri, 15 Jan 2021, Artur Bala wrote:
> Dear developers,
> I thought that the following "if" conditions are supposed to give the
> same
> results but they actually don't. And the 2nd "if" block ignores
"NA"
> values
Interesting.
The problem you report can be exemplified even more easily as
...
I'm not sure what we should do in an "if" block if the condition is
neither true or false. At the moment, we treat NA as true (because it's
non-zero), but I wonder if we should throw an error instead.
Even shorter:
if NA
print "here" # does indeed print it
endif
This looks very wrong to me. Actually I don't think it should be an
error but should behave just like Artur's other syntax variants,
yielding FALSE. Isn't every boolean evaluation involving NAs FALSE by
convention?
[BTW Artur, some unrelated --and unsolicited, sorry!-- comments on the
syntax in your example:
"loop for i=" is tolerated but not really correct, it's just "loop
i="
for the simple index loop.
And "test2 = abs(x) >= 0.5 ? 1 : 0" would also just work with the
i-indices and the surrounding explicit loop. The looping is then done
internally and should be much faster.]
thanks
sven