diff --git a/p4-16/spec/P4-16-spec.adoc b/p4-16/spec/P4-16-spec.adoc index 37940fb202..c583233aa5 100644 --- a/p4-16/spec/P4-16-spec.adoc +++ b/p4-16/spec/P4-16-spec.adoc @@ -3841,18 +3841,23 @@ Additionally, the maximum size of a variable-length bit-string can be determined [#sec-casts] === Casts -P4 provides a limited set of casts between types. A cast is written -`(t) e`, where `t` is a type and `e` is an expression. Casts are only -permitted on base types and derived types introduced by `typedef`, `type`, and `enum`. -While this design is arguably more onerous for programmers, it has several benefits: +P4 provides a set of casts between types. A cast is written +`(t) e`, where `t` is a type and `e` is an expression. Casts in P4 are +permitted only under the conditions specified in section <> +for explicit casts and section <> for implicit casts. +By allowing casts only in limited scenarios, this restriction is more +onerous for programmers, but it also provides several benefits. * It makes user intent unambiguous. * It makes the costs associated with converting numeric values explicit. Implementing certain casts involves sign extensions, and thus can require significant computational resources on some targets. * It reduces the number of cases that have to be considered in the P4 - specification. Some targets may not support all casts. + specification. +Some targets may not support all casts. + +[#sec-explicit-casts] ==== Explicit casts The following casts are legal in P4: