General/Unconditional/Infinite Loops in activity diagrams

+1 vote
asked Jan 29, 2021 in Wanted features by c.milkau.prologa (120 points)

Desired result

Repeat and while loops are just special cases. While they are common in code, in more high-level process descriptions I almost always need the general case, which looks something like this:

@startuml state "before loop"      as before state "inside the loop" as loop {   state "loop join"        as join <<choice>>   state "before condition" as unconditional : empty in "while" loops   state "loop condition"   as test <<choice>>   state "after condition"  as continue : empty in "repeat" loops } state "after loop"       as after  before   -d-> join  : enter loop join     -d-> unconditional unconditional -d-> test : condition test test     -l-> after     : break loop test     -d-> continue  : continue loop continue -u-> join      : close loop continue -d[hidden]-> after @enduml

Is there any way to achieve that already?

What doesn't work

Note that:

  1. Using a "while" loop for this makes an extra arc from the loop start to "after loop"
  2. Using a "repeat" loop for this makes an extra arc from the loop end to "after loop"
  3. Using "detach" or "kill" after the loop will remove or cut the arc from the condition test to "after loop"

Suggested Syntax

If it doesn't exist yet, this is how I would suggest to support it (new syntax in bold):

@startuml
:before loop;
repeat
  :before condition;
  if (condition test) then (break loop)
    break
  else (continue loop)
  endif
  :after condition;
repeat forever
:after loop;
@enduml

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...