Opened 10 years ago
Last modified 4 years ago
#2897 reopened enhancement
continue statement for for- and while-statements
Reported by: | Per Östlund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | MetaModelica | Version: | trunk |
Keywords: | Cc: | Adrian Pop, Peter Fritzson |
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)
follow-up: 2 comment:1 by , 10 years ago
comment:2 by , 10 years ago
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 by , 10 years ago
Milestone: | Bootstrapping → 1.9.1 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fixed in r22782.
comment:4 by , 10 years ago
Cc: | added |
---|---|
Resolution: | fixed |
Status: | closed → 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 by , 10 years ago
Milestone: | 1.9.1 → 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 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:11 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:12 by , 7 years ago
Milestone: | 1.12.0 → 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 by , 4 years ago
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...
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?