p4-spec
p4-spec copied to clipboard
language evolution: "optional" should be a keyword
"@optional
" being a mere annotation presents difficulties, obstacles, problems, and roadblocks for compiler developers.
If it were a keyword, then it would be clear that skipping it is non-optional, pun fully intended.
This would be a backwards-incompatible change, of course. Furthermore, dropping support for "@optional
" would be even more backwards-incompatible. Therefor, I propose a multi-stage solution...
- language version 'n': add "
optional
" to the spec., make it mean the same thing as "@optional
", make the Open Source compiler warn when old-fashioned "@optional
" is found (e.g.WARNING: this syntax is deprecated... please alter your code to use the new-in-P4₂₃ keyword "optional". Support for "@optional" will be removed in the next language version.
) and recommend that other P4 compilers with support for language version 'n' do the same. - language version "n+1": remove support for "
@optional
" from the spec., make it clear to all developers of P4 compilers that when their compiler "sees" "@optional
" when in {language version "n+1" mode} it should error out with a clear error message telling the user what is wrong with the P4 code and what (s)he could do about it (i.e.: either replace "@optional
" with "optional
" everywhere in the P4 code, or... compile in an older mode, e.g. P4₁₆, if still supported by the respective compiler).
Unfortunately, optional
is already a match_kind
in V1Model architecture. So if we add it as a keyword (and don't do something special in the front-end) we would break one of the most widely used architectures.
In hindsight, it seems like using the word optional
for both @optional
annotation and the name of a match_kind might not have been a great idea, but perhaps that is water under the bridge now?
Perhaps @Abe149's two-step plan could use some syntax other than adding the prefix optional
as the replacement of @optional
?
Does anyone still feel strongly about this? If not, should we close it?
Given the silence, I'm going to mark this as closed.