Opened 10 years ago
Last modified 4 years ago
#2897 reopened enhancement
continue statement for for- and while-statements
Reported by: | perost | Owned by: | sjoelund.se |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | MetaModelica | Version: | trunk |
Keywords: | Cc: | adrpo, petfr |
Description
Modelica/MetaModelica is currently lacking a continue statement for breaking out of the current iteration of a for- or while-loop, which can be somewhat annoying. Considering that C (and pretty much any language with for-loops) already has this builtin it should be fairly trivial to implement. I suggested adding it to Modelica here, but we could implement it in MetaModelica without waiting for that.
Change History (14)
comment:1 follow-up: ↓ 2 Changed 10 years ago by sjoelund.se
comment:2 in reply to: ↑ 1 Changed 10 years ago by perost
Replying to sjoelund.se:
How would you like it added initially? It requires a lexer change and the keyword continue is used as a variable name in omc. The grammar conflicts such that you cannot have variables named continue.
Change all current uses of continue to cont?
Sure, it doesn't seem to be used that much currently. continue is pretty universally used for this purpose, so I think it would be confusing to call it something else.
comment:3 Changed 10 years ago by sjoelund.se
- Milestone changed from Bootstrapping to 1.9.1
- Resolution set to fixed
- Status changed from new to closed
Fixed in r22782.
comment:4 Changed 10 years ago by sjoelund.se
- Cc adrpo petfr added
- Resolution fixed deleted
- Status changed from closed to reopened
We need to decide what continue should do in a match/matchcontinue block. The current implementation is that:
x := match exp case _ equation continue; // Continues with the next case then fail(); case _ equation break; // Returns undefined values from the match-expression then fail();
comment:5 Changed 10 years ago by sjoelund.se
- Milestone changed from 1.9.1 to 1.9.2
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:6 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.2 to 1.9.3
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:7 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.3 to 1.9.4
Moved to new milestone 1.9.4
comment:8 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.4 to 1.9.5
Milestone pushed to 1.9.5
comment:9 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.5 to 1.10.0
Milestone renamed
comment:10 Changed 8 years ago by sjoelund.se
- Milestone changed from 1.10.0 to 1.11.0
Ticket retargeted after milestone closed
comment:11 Changed 8 years ago by sjoelund.se
- Milestone changed from 1.11.0 to 1.12.0
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:12 Changed 7 years ago by casella
- Milestone changed from 1.12.0 to Future
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
comment:13 Changed 4 years ago by perost
continue is currently used in the following pattern in a few places (Inline.getExpFromArgMap and BackendDAEOptimize.simplifyComplexFunction1):
for ... loop try ... else continue; end try; end for;
This is wrong since try-else is just syntactic sugar for a matchcontinue, so this will currently not do what the author intended.
There are however no uses of continue that assume that it continues with the next case, so the logical thing to do would be to change continue and break to only affects loops. That might be easier said than done though...
comment:14 Changed 4 years ago by sjoelund.se
Ideally the DAE would contain labels that you would jump to :)
How would you like it added initially? It requires a lexer change and the keyword continue is used as a variable name in omc. The grammar conflicts such that you cannot have variables named continue.
Change all current uses of continue to cont?