p4-spec
p4-spec copied to clipboard
Support for `typeof` keyword
Personnel
- [x] Owner: @mbudiu
- [x] Supporters: @vgurevich
Design
- [x] Document: this PR
Implementation
- [x]
p4-spec: this PR - [x]
p4c: https://github.com/p4lang/p4c/pull/3017
Process
- [ ] LDWG discussed:
- [ ] LDWG approved:
- [ ] Merged into
p4-spec: - [ ] Merged into
p4c:
This would be only really useful in conjunction with #1011. If #1011 is not accepted, a different design should be used for this feature. The reason is that typedef declarations being global confines the use of typeof only for constant expressions, and P4 currently does not have constant expressions of some types, such as header stacks.
We discussed this feature at the April '22 LDWG meeting.
- Folks should try this feature out, as well as #1011 and come with feedback for the May meeting.
- @mbudiu-vmw will also prototype a version that allows
typeofanywhere a type can be indicated... if Bison allows it.
@vgurevich especially, please take a look!
@jnfoster -- noted. I'll try to refactor some programs and at least compile them with p4-test backend.