From ba48ceff79786f3bea20138daaaa632753b0bb35 Mon Sep 17 00:00:00 2001 From: Sehyuk Ahn Date: Tue, 14 Apr 2026 13:23:41 +0900 Subject: [PATCH] explicitly disallow optional parameters in parsers and controls, deprecate optional parameters in abstract methods Signed-off-by: Sehyuk Ahn --- p4-16/spec/P4-16-spec.adoc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/p4-16/spec/P4-16-spec.adoc b/p4-16/spec/P4-16-spec.adoc index 0c3460083d..4b6a399913 100644 --- a/p4-16/spec/P4-16-spec.adoc +++ b/p4-16/spec/P4-16-spec.adoc @@ -1680,12 +1680,14 @@ void g() A parameter that is annotated with the `@optional` annotation is optional: the user may omit the value for that parameter in an invocation. Optional parameters can only appear for arguments of: -packages, parser types, control types, extern functions, extern methods, and extern object -constructors. Optional parameters cannot have default values. If a -procedure-like construct has both optional parameters and default values then it -can only be called using named arguments. It is recommended, but not -mandatory, for all optional parameters to be at the end of a parameter -list. +packages, parser types, control types, extern functions, extern methods, and +extern object constructors. Note that optional parameters are not allowed in +parser declarations and control declarations. Allowing optional parameters in +abstract methods is deprecated, and is planned to be disallowed in the future. +Optional parameters cannot have default values. If a procedure-like construct +has both optional parameters and default values then it can only be called +using named arguments. It is recommended, but not mandatory, for all optional +parameters to be at the end of a parameter list. The implementation of such objects is not expressed in P4, so the meaning and implementation of optional parameters should be specified