Feature: if X then
Opened this issue · 2 comments
Please introduce implicit style cast to bool for branching statements, based on new is_truthy
opcode. not
keyword should also be supported.
Example:
int isOk, error
(...)
if and
isOk
not error
then
would be compiled to:
if and
is_truthy {value} 0@
not is_truthy {value} 1@
then
Please note is_truthy
supports all variable types (including strings) and immediate values (constants). All of these are desirable as condition in branching.
New behavior should be applicable to all branching constructs (if, while, repeat, etc.)
because of the way data is handled in the script you could only evaluate this data as such:
- any empty string is FALSY.
- any number 0, is FALSY.
that's all.
by default all variables are set to 0.
That's how the is_truthy works now. In other languages there are more values treated as false (float NaN for example), but it is not always possible to tell what type the variable data is in SCM.