Below is the code example from spec section 8.24 explaining the operations on types that are type variables.
A local variable x of type T is defined inside the apply block of a control declaration.
control C<T>() {
apply {
T x; // the type of x is T, a type variable
}
}
However, section 14 on control block mentions that,
Unlike control type declarations, control declarations may not be generic
So the above example is an invalid P4 program where C is a generic control declaration (not a control type declaration).
I believe below example would be more appropriate for the purpose.
void f<T>() {
T x; // the type of x is T, a type variable
}
Below is the code example from spec section 8.24 explaining the operations on types that are type variables. A local variable
x
of typeT
is defined inside the apply block of a control declaration.However, section 14 on control block mentions that,
So the above example is an invalid P4 program where
C
is a generic control declaration (not a control type declaration). I believe below example would be more appropriate for the purpose.