-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New BREAK
and CONTINUE
statements for controlling FOR
and WHILE
loop execution
#4079
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
Comments
One obvious thing to decide is what we do with A related question is what to do with conditional variants |
Single line IF option would be great. The new IF syntax is soooo much better for conditional blocks than the prior I would never choose having to put
So if the I know this is not how python works but it’s not a completely made up concept either AppleScript (another keyword language) is a good example. They call this “if (simple)” and “if (compound)”. They use the pattern a lot all over too for example IMO that’s the right thing to do, Robot’s roots is a keyword language so even though it’s python based, forcing it to behave with the same pythonic rules (inconveniences) that python has when there is a more natural way to do things will make it too close to python and it looses it’s value prop of simple natural-language-like readability with a focus on telling what’s being tested and not distracting with how the test has to be written. |
The above syntax to run single keyword with IF looks pretty good. Would need to think should we also support ELSE and ELSE IF and should we allow assignment:
This discussion definitely needs its own issue. Could you @ericbjones submit one? |
I wrote instructions to #4078 (comment) about how to get started with adding |
Break and Continue
Continue and Break Lexers modified
Break and Continue Lexer added in blocklexers.py
Continue and Break definitions added in Builtin.py
Implementation continue and break. Initial commit
- Mention, and recommend, RETURN in "Return From Keyword (If)" docs. - Enhance error message if RETURN used in test inside IF or FOR. - Fix "Return From Keyword (If)" tests after message changed. - Change messages used by "Continue/Exit For Loop (If)". They needed to be changed anyway when adding BREAK and CONTINUE (#4079).
Initial commit for the Continue and Break statements.
Initial level review comments incorporated.
Exit and Continue for loop
Changes in BuiltIn file removed.
KeywordCallLexer was removed by mistake
BREAK
and CONTINUE
statemens for FOR
loop controlBREAK
and CONTINUE
statemens for controlling FOR
and WHILE
loop execution
There is one open design decision related to
I pretty firmly believe My current thinking is to handle this as follows:
Notice that although I wrote "directly inside a loop" above, UPDATE: We decided to allow |
Basic implementation of CONTINUE and BREAK (issue #4079). Things to do: - Acceptance tests - Documentation - Cleanup
Initial implementation was been done by @bbpatel2001 in already merged PR #4136. Big thanks for contribution! Things to do:
|
- Update output.xml schema - Fix visitor interface and thus also Rebot - Fix listener interface in general (needed to add source) - Fix situation when listener runs keyword in `start/end_keyword` with BREAK, CONTINUE and also RETURN. - Enhance tests for listeners logging keywords also with WHILE and TRY.
…lures. Also fix using BREAK and CONTINUE directly under WHILE (i.e. not nested in IF or TRY).
This ought to be now done except for documentation that is covered by #4203. This issue can now be closed. Big thanks again for @bbpatel2001 for the initial PR! |
BREAK
and CONTINUE
statemens for controlling FOR
and WHILE
loop executionBREAK
and CONTINUE
statements for controlling FOR
and WHILE
loop execution
Uh oh!
There was an error while loading. Please reload this page.
We currently have
Exit For Loop
(#502) andContinue For Loop
(#1125) keywords for this purpose. Having explicit statements would make the usage more clear and closer to how "real" programming languages handle loops. This is especially important when we addWHILE
loops (#4084).When
Exit For Loop
was added (#502), we decided to use that name instead ofBreak
orBreak For Loop
because the exiting sounds more natural for non-programmers. That's still a valid point, but I believe these new statements should be named the same way as they commonly are named in other languages. That way they are more familiar for programmers and also people learning basics of programming using Robot's syntax will have it easier to learn other languages later.See also #4078 about adding somewhat similar
RETURN
statement.The text was updated successfully, but these errors were encountered: