-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify explanation on casting types that are not base type and derived types introduced by typedef, type, and enum #1351
Comments
Below is one suggested wording for the revised sentence that you gave in your comment as:
I don't claim it is the best way, but I'm going for accuracy here:
I think that might be an exhaustive list, but I might be missing something. We could introduce a name for everything encompassed by the "expressions that are syntactically one of ..." and its sub-bullets, but it might not be worth the effort, if that name would only be used one place in the spec. |
Thank you for the suggestion :) I also think that the list is exhaustive. On second thought, for the readability of the spec, introducing such a detailed explanation may be a bit redundant. Because section 8.11.1 immediately follows the explanation and also exhaustively listing all possible casts. And I have also noticed that "casts are only permitted on base types" can also be inaccurate, in the sense that we do not allow casts on some base types, such as So how about this revision:
This explains that casts apply to limited occasions in P4, but puts a forward reference to the following subsections instead of listing them exhaustively. |
Looks good to me. Feel free to create a PR with that change for review. |
The spec mentions about casting at the beginning of section 8.11. Casts.
But in the description of explicit casts in section 8.11.1. Explicit Casts, we also consider the case that is not a base type nor a derived type introduced by typedef, type, and enum:
And section 8.13. Operations on structure-valued expressions elaborates more:
So, I believe there is some gap between what is claimed at the beginning of section 8.11 and what is explained in 8.11.1 and 8.13.
(1) Suggestion for revising 8.11
I propose changing the explanation in 8.11 to better reflect the below cases:
But currently I cannot think of a right phrase to capture this. As of my knowledge, the spec does not define an explicit type for key-value lists and tuple(list) expressions. So it doesn't nicely fit into the explanation:
(Current) Casts are only permitted on base types and derived types introduced by typedef, type, and enum.
(Revised) Casts are only permitted on base types, (some nice way to phrase key-value list, list, and {#} types), and derived types introduced by typedef, type and enum.
(2) Relation to p4c test
Also, I wonder if this program (
issue3233.p4
) is in line with the current spec. This, when given to the p4c frontend, is rejected.A related discussion was made in this issue.
But since the spec has mentioned that: casting a key-value list is valid, can we consider the above program as valid?
The text was updated successfully, but these errors were encountered: