Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: if X then #318

Open
MiranDMC opened this issue Apr 13, 2024 · 2 comments
Open

Feature: if X then #318

MiranDMC opened this issue Apr 13, 2024 · 2 comments
Labels
priority:p2 Medium priority scope:compiler type:feature New feature or request

Comments

@MiranDMC
Copy link

MiranDMC commented Apr 13, 2024

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

@x87 x87 added type:feature New feature or request priority:p2 Medium priority scope:compiler labels Apr 13, 2024
@MatiDragon-YT
Copy link
Member

MatiDragon-YT commented Apr 21, 2024

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.

@MiranDMC
Copy link
Author

MiranDMC commented Apr 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Medium priority scope:compiler type:feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants