Consistency of arrow syntax between state and deployment diagrams

0 votes
asked Oct 9, 2021 in Question / help by Martin (8,360 points)

I thought I was going mad:  I was trying to add a direction qualifier to a single-dash arrow in a deployment diagram and was getting a syntax error.  I was sure I had seen it used before - turns out that it is valid syntax on a state diagram.  Is there a good reason it is allowed for State but not for Deployment?

@startuml

rectangle A [
{{
state a
state b
a -l> b
}}
]

rectangle B [
{{
rectangle a
rectangle b
a -l> b
}}
]

@enduml

Conversely, you can reverse arrows in Deployment but not in State:

@startuml
rectangle A [
{{
state a
state b
b <- a
}}
]

rectangle B [
{{
rectangle a
rectangle b
b <- a
}}
]
@enduml

This kind of inconsistency of syntax can be quite confusing.  Is there a valid technical reason for it?

1 Answer

0 votes
answered Oct 10, 2021 by plantuml (295,000 points)
selected Oct 10, 2021 by Martin
 
Best answer

Many thanks for your feedback!

About your first point, you should use the official syntax, which is a -l-> b

It's only by chance that the parser accepts a lazzy form for State Diagram. We could raise now an error message in that case, but we are reluctant to break any existing and working diagrams, so we won't. However, you should not use it anymore.

About point 2, you are right and this has been fixed in last beta http://beta.plantuml.net/plantuml.jar 

This kind of inconsistency of syntax can be quite confusing.  Is there a valid technical reason for it?

Sorry about that: the technical reason is that there are two different parsers for StateDiagram and DeploymentDiagram. This is because features are not exactly the same for both diagrams.This give a great flexibility for parsers but it means that we have to manually ensure consistence between both syntaxes, which is not 100% complete, as you have found.

...