Comments (7)
However, the spec implies that this is not true.
from p4-spec.
@mbudiu-vmw wrote: "Second, there is no discussion about the semantics of assigning invalid fields."
It appears to me that the spec is quite explicit on this topic. Quoting from Section 8.19 "Operations on Header Unions" below:
We can understand an assignment to a union field
u.hi = e
as equivalent to
u.hi.setValid();
u.hi = e;
if e is valid and
u.hi.setInvalid();
otherwise.
If I am interpreting that correctly, then your example code in the original comment above:
header_union HU { H1 h1; H2 h2; }
HU u;
H1 h;
h.setInvalid();
u.field =h;
The spec explicitly says that the u
should end in a state where all of its members are invalid.
How can that section of the spec be interpreted otherwise?
from p4-spec.
The spec does not explain whether an existing valid field is invalidated when assigning a different field with an invalid value. Either interpretation would be possible.
from p4-spec.
Please read the entire section on operations on header unions and tell me if you still believe it is open to interpretation. I don't see how it is. For example, see this text:
More formally, if u is an expression whose type is a header union U with fields ranged over by hi, then the following operations can be used to manipulate u:
u.hi.setValid(): sets the valid bit for header hi to true and sets the valid bit for all other headers to false, which implies that it is unspecified what value reading any member header of u will return.
u.hi.setInvalid(): if the valid bit for any member header of u is true then sets it to false, which implies that it is unspecified what value reading any member header of u will return.
from p4-spec.
If you mean that this phrase is ambiguous "if the valid bit for any member header of u is true then sets it to false", I believe the intent when it was written was more explicitly the following.
"assign false to the valid bit for every member header of u"
I would be open to changing that sentence to be more explicit if you think it is open to interpretation.
from p4-spec.
Fixed by #1220
from p4-spec.
Closing this issue, as it appears to have been resolved by the commit mentioned by Mihai above.
from p4-spec.
Related Issues (20)
- @optional annotation wording is confusing HOT 1
- Add expression to represent an invalid header_union value HOT 3
- Compiler should not expand stack copying in parsers
- Loose description of implicit cast HOT 4
- There is no section on "operations on extern objects" HOT 4
- Should switch statements and select expressions be unified? HOT 3
- Reason for limiting fixed-length types to have a constant width HOT 5
- Sum QoS throughout HOT 3
- Include no-op casts (t -> t) in list of explicit casts HOT 1
- Allow easier casting of serializable enum to a different bit width HOT 5
- Original source of editable figures in the language spec? HOT 3
- Rationale for allowing 0-width type `bit<0>` ? HOT 6
- Confusing note about `action_run` switch HOT 4
- Introduce compile-time bounded for loops and if statements inside of `entries` table property HOT 16
- Should it be legal to have a reference of an extern type name within the definition of that extern? HOT 7
- All spec links from p4.org are broken HOT 2
- Add dynamic array to P4 HOT 13
- Streaming the payload HOT 1
- Language for specifying P4_16 architectures HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p4-spec.