dev icon indicating copy to clipboard operation
dev copied to clipboard

Feature: if X then

Open MiranDMC opened this issue 1 year ago • 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.)

MiranDMC avatar Apr 13 '24 07:04 MiranDMC

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.

MatiDragon-YT avatar Apr 21 '24 18:04 MatiDragon-YT

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.

MiranDMC avatar Apr 21 '24 18:04 MiranDMC