Skip to content
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

Change semantics of abbreviated form of field conditions #617

Closed
treiher opened this issue Mar 25, 2021 · 2 comments · Fixed by #705
Closed

Change semantics of abbreviated form of field conditions #617

treiher opened this issue Mar 25, 2021 · 2 comments · Fixed by #705
Assignees
Labels
architectural decision Discussion of design decision model Related to model package (e.g., model verification) specification Related to specification package (e.g., specification parsing)

Comments

@treiher
Copy link
Collaborator

treiher commented Mar 25, 2021

Context and Problem Statement

The current semantics of conditions at message fields (without using a then-clause) seems to be confusing. A field definition of the form F : T if C adds the condition C to all incoming edges of F. Because of that semantic it is not possible to reference F in condition C, although F is syntactically mentioned before C. Here is a more complex example inspired by IPv4 packets:

package Test is

   type Length is range 5 .. 2**16 - 1 with Size => 16;
   type Address is mod 2**32;

   type M1 is
      message
         IHL : Length;
         Total_Length : Length
            then Source
               if Total_Length >= IHL * 4;
         Source : Address;
         Destination : Address
            then Options
               with Size => IHL * 32 - (Destination'Last - Message'First + 1);
         Options : Opaque
            then Payload
               with Size => Total_Length * 8 - (IHL * 32);
         Payload : Opaque;
      end message;

   type M2 is
      message
         IHL : Length;
         Total_Length : Length;
         Source : Address
            if Total_Length >= IHL * 4;
         Destination : Address;
         Options : Opaque
            with Size => IHL * 32 - (Destination'Last - Message'First + 1);
         Payload : Opaque
            with Size => Total_Length * 8 - (IHL * 32);
      end message;

   type M3 is
      message
         IHL : Length;
         Total_Length : Length
            if Total_Length >= IHL * 4;  -- error: undefined variable "Total_Length"
         Source : Address;
         Destination : Address;
         Options : Opaque
            with Size => IHL * 32 - (Destination'Last - Message'First + 1);
         Payload : Opaque
            with Size => Total_Length * 8 - (IHL * 32);
      end message;

end Test;

M1 shows the message specification in the regular form using then-clauses. In the current implementation, M2 is a semantically equivalent variant of M1 using the abbreviated forms for conditions and size aspects. M3 is invalid, as Total_Length is referenced in the incoming edge to Total_Length, although it seems to be the more intuitive way of adding the condition.

Considered Options

O1 Add field conditions to incoming edges of field (keep current implementation)

+ Consistent behavior of aspects and conditions in abbreviated form (i.e. for transforming the regular into the abbreviated form the with ... as well as if ... has to be moved to the subsequent field): A : T then B if C with Size => 8; B : Opaque; is equivalent to A : T; B : Opaque if C with Size => 8;.
Being unable to reference field containing condition feels intuitive (cf. M2)

O2 Add field conditions to outgoing edges of field

+ More intuitive (cf. M3)
+ Allows adding conditions to last message field without then null (cf. TLS Alert)

Decision Outcome

O2

@treiher treiher added model Related to model package (e.g., model verification) specification Related to specification package (e.g., specification parsing) labels Mar 25, 2021
@treiher treiher added this to To do in RecordFlux 0.7 via automation Mar 25, 2021
@treiher
Copy link
Collaborator Author

treiher commented Mar 25, 2021

I think changing the semantics (O2) would be worth the effort. The behavior is more intuitive and makes specifications clearer and easier understandable.

@treiher treiher removed this from To do in RecordFlux 0.7 Mar 25, 2021
@treiher treiher added this to To do in RecordFlux 0.5 via automation Mar 25, 2021
@senier
Copy link
Member

senier commented Mar 25, 2021

I think changing the semantics (O2) would be worth the effort. The behavior is more intuitive and makes specifications clearer and easier understandable.

That's what we should do (as discussed separately)

@treiher treiher changed the title Semantics of abbreviated form of field conditions Change semantics of abbreviated form of field conditions Jul 12, 2021
@treiher treiher added the architectural decision Discussion of design decision label Jul 12, 2021
@treiher treiher moved this from To do to In progress in RecordFlux 0.5 Jul 23, 2021
treiher added a commit that referenced this issue Jul 23, 2021
@treiher treiher moved this from In progress to Under review in RecordFlux 0.5 Jul 23, 2021
@treiher treiher self-assigned this Jul 23, 2021
RecordFlux 0.5 automation moved this from Under review to Merged Jul 27, 2021
treiher added a commit that referenced this issue Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architectural decision Discussion of design decision model Related to model package (e.g., model verification) specification Related to specification package (e.g., specification parsing)
Projects
No open projects
RecordFlux 0.5
  
Merged
Development

Successfully merging a pull request may close this issue.

2 participants