p4-spec icon indicating copy to clipboard operation
p4-spec copied to clipboard

Generic typedefs

Open mihaibudiu opened this issue 4 years ago • 1 comments

Personnel

  • [x] Owner: @mbudiu-vmw
  • [x] Supporters: @jnfoster

Design

  • [x] Document: See below

Implementation

  • [ ] p4-spec:
  • [ ] p4c: https://github.com/p4lang/p4c/pull/2706

Process

  • [ ] LDWG discussed:
  • [ ] LDWG approved:
  • [ ] Merged into p4-spec:
  • [ ] Merged into p4c:

=======================================

Currently a typedef can introduce a new identifier. But it cannot be used to introduce a new generic type, as in:

#define V1MODEL_VERSION 20210101
#include <v1model.p4>

typedef register<T, bit<8>> reg8<T>;
reg8<bit<12>> r(100);

mihaibudiu avatar Apr 19 '21 21:04 mihaibudiu

I can see where this would be useful. The other thing that might be useful is defaults for type parameters. Though defaults can get hairy in some cases, especially if it is allowed to be depedent on the previous type parameter (e.g. header h<T, T1 = other<T>> {} )

apinski-cavium avatar May 14 '22 23:05 apinski-cavium

In the interest of tidying up the set of active issues on the P4 specification repository, I'm marking this as "stalled" and closing it. Of course, we can always re-open it in the future if there is interest in resurrecting it.

jnfoster avatar Nov 11 '23 13:11 jnfoster