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

Semantics of length aspect and attribute in message specification #421

Closed
treiher opened this issue Aug 31, 2020 · 1 comment · Fixed by #471
Closed

Semantics of length aspect and attribute in message specification #421

treiher opened this issue Aug 31, 2020 · 1 comment · Fixed by #471
Assignees
Labels
specification Related to specification package (e.g., specification parsing)

Comments

@treiher
Copy link
Collaborator

treiher commented Aug 31, 2020

Current State

A size aspect specifies the bit length of a type:

   type Length is range 1 .. 255 with Size => 8;

A length aspect allows to define the bit length of the following field, if this field is opaque or an array:

         L : Length
            then O
               with Length => L * 8;
         O : Opaque;

A length attribute can be used to refer to the length of the message:

         null
            then O
               with Length => Message'Length;
         O : Opaque;

Issues

I1: Inconsistency

While Size is used for the bit length of a type, Length is used for the bit length of a field and message. #384 proposes the use of a Size attribute in expressions:

         L : Length
            then O
               with Length => Message'Length - Package.Length'Size;
         O : Opaque;

'Length and 'Size give the impression that they mean different things, but actually both refer to the bit length. There is no clear rule why Length is used in the one case and Size in the other.

I2: Useless Conversion

The bit length of an opaque or array field must always be a multiple of 8. As in common binary formats the length is given in bytes, this leads to the need for the addition of * 8 (I'm not aware of any counter example).

Options

O1: Differentiate between bit length and byte length

Change the meaning of Length to represent the byte length (instead of the bit length). This would solve I1 as well as I2.

O2: Consistently use bit length

Replace all uses of Length by Size (or Size by Length) to reflect that both refer to the bit length of some entity. This would solve I1, but not I2.

Discussion

I think in any case the consistency issue (I1) should be resolved. I'm not sure, if also I2 should be fixed in this course. The main question is, if there should be a differentiation between bit length and byte length in the specification (O1). The disadvantage of O1 would be the increased complexity: Both cases need to be handled correctly, and also a user has to correctly differentiate both cases. For the latter another naming would be better (e.g., Size and Byte_Size instead of Size and Length).

@treiher treiher added the specification Related to specification package (e.g., specification parsing) label Aug 31, 2020
@treiher
Copy link
Collaborator Author

treiher commented Aug 31, 2020

In a separate discussion we decided to only use bit lengths in the specification (O2). Length will be renamed to Size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
specification Related to specification package (e.g., specification parsing)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant