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

continue (X.) continues indiscriminately #11

Closed
digital-carver opened this issue Nov 16, 2023 · 2 comments
Closed

continue (X.) continues indiscriminately #11

digital-carver opened this issue Nov 16, 2023 · 2 comments

Comments

@digital-carver
Copy link
Contributor

Hi! Is it intended that continue (X.) goes to the next iteration without checking the stack?

The manual says "the loop proceeds with the next iteration, if any" - the "if any" part makes it sound like it should check the stack like the loop usually does, and go the next iteration only if it's truthy. That's the behaviour I'd expect from other languages too - continue means skip the rest of the loop, but do check the loop condition again. It seems like that's not the behaviour in MATL, from some testing:

Without continue

octave:1> matl 'F T X` X# '
/-------
STACK{1} = 

0

-------/

With continue at the end of loop

octave:2> matl 'F T ` X# X.'
/-------
STACK{1} = 

0

-------/
/-------
STACK{1} = 

0

-------/
/-------
STACK{1} = 

0

-------/

(output goes on indefinitely, loop doesn't terminate)

@lmendo
Copy link
Owner

lmendo commented Nov 16, 2023

Thank you for catching this! Yes, it should be fixed. I think I know what I need to change in the compiler to achieve the desired behaviour, but I don't have the time now. I'll do it within the next few days. This affects both "while" and "do while" loops

@lmendo
Copy link
Owner

lmendo commented Nov 21, 2023

This should be fixed now with the latest commit. It can be tested in MATL Online:

https://matl.io/?code=F+T+%60+X%23+X.&inputs=&version=f0400d41

Thanks again!

@lmendo lmendo closed this as completed Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants