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

Clarifications on range operators #1127

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions p4-16/spec/P4-16-spec.mdk
Original file line number Diff line number Diff line change
Expand Up @@ -4129,16 +4129,20 @@ values.
### Ranges { #sec-ranges }

The infix operator `..` takes two arguments of the same type `T`,
where `T` is either `bit<W>` or `int<W>`, and creates a value of
type `set<T>`. The set contains all values numerically between the
first and the second, inclusively. For example:
where `T` is either `bit<W>`, `int<W>`, or a serializable enum value,
and creates a value of type `set<T>`. The set contains all values
numerically between the first and the second, inclusively. For
example:

~ Begin P4Example
4w5 .. 4w8
~ End P4Example

denotes a set with values `4w5, 4w6, 4w7`, and `4w8`.

A range where the second value is smaller than the first one
represents an empty set.

### Products { #sec-tuples-of-sets }

Multiple sets can be combined using Cartesian product:
Expand Down Expand Up @@ -8344,6 +8348,8 @@ The P4 compiler should provide:

## Summary of changes made in version 1.2.4

* Clarified semantics of ranges where the start is bigger than the end (Section [#sec-ranges]).
* Allow ranges to be specified by serializable enums (Section [#sec-ranges]).
* Specified type produced by the `*sizeInB*` methods (Section [#sec-minsizeinbits]).
* Added section with operations on `match_kind` values (Section [#sec-match-kind-exprs]).

Expand Down