sannybuilder / dev

Sanny Builder Bug Tracker and Roadmap development
https://sannybuilder.com
49 stars 0 forks source link

Feature: if X then #318

Open MiranDMC opened 7 months ago

MiranDMC commented 7 months ago

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.)

MatiDragon-YT commented 6 months ago

because of the way data is handled in the script you could only evaluate this data as such:

that's all. by default all variables are set to 0.

MiranDMC commented 6 months ago

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.