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

Shorter syntax for integer types covering entire value range #1250

Open
treiher opened this issue Nov 8, 2022 · 0 comments
Open

Shorter syntax for integer types covering entire value range #1250

treiher opened this issue Nov 8, 2022 · 0 comments
Labels
architectural decision Discussion of design decision specification Related to specification package (e.g., specification parsing)

Comments

@treiher
Copy link
Collaborator

treiher commented Nov 8, 2022

Context and Problem Statement

Declaring an integer type which covers the entire value range can be quite cumbersome:

type T is range 0 .. 2 ** 16 - 1 with Size => 16;

Use Cases

There are many cases in message formats of real world protocols where such integers are required.

Considered Options

O1 Optional Size aspect

type T is range 0 .. 2 ** 16 - 1;

+ No new keyword
Implicit determination of type size could be confusing for user

O2 Box instead value range

type T is range <> with Size => 16;

+ No new keyword
range <> does also occur in Ada, but in different context, so could be confusing for Ada programmers

O3 New keyword

O3.1

type T is size 16;

+ Concise
New keyword (with the same name as an existing aspect)

O3.2

type T is unsigned 16;

+ Concise
+ Can be extended by signed keyword for signed integer types
New keyword

O4 Reuse syntax of modular types

type T is mod 2**16;

Well-known syntax for Ada programmers, but different semantics as in Ada (cf. #727)

Decision Outcome

O3.2

@treiher treiher added specification Related to specification package (e.g., specification parsing) architectural decision Discussion of design decision labels Nov 8, 2022
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 specification Related to specification package (e.g., specification parsing)
Projects
None yet
Development

No branches or pull requests

1 participant