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

Labeled blocks #2

Open
benburrill opened this issue Nov 24, 2023 · 0 comments
Open

Labeled blocks #2

benburrill opened this issue Nov 24, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@benburrill
Copy link
Owner

Sometimes in order to get the desired control flow, it is necessary to introduce ancillary variables in Halt is Defeat that would not be needed in Sphinx. For example:

bool do_something = true;
preempt { do_something = false; }
if (do_something) {
    something();
}

Semantically equivalent Sphinx code:

j skip_something
; CALL something
skip_something:

This sort of code is fairly common, which I see as a symptom of Halt is Defeat's somewhat haphazard design / choice of abstractions, but a bandaid solution to allow for more flexible control flow would be to add labeled blocks. For the above code, this would allow:

do_something: {
    preempt { break do_something; }
    something();
}

Labeled loops should allow continue LABEL and break LABEL. Other labeled blocks should only allow break LABEL.

@benburrill benburrill added the enhancement New feature or request label Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant