Gradual 'tree' typing and C++
Debate continues on gradual typing for GCC's tree representation; Jakub Jelinek argues against it, citing increased complexity and lack of benefit for typical…
Jakub Jelinek reiterates his rejection of the gradual ‘tree’ typing proposal, characterizing it as ‘extra pain.’ He elaborates that while static typing might offer theoretical advantages in some scenarios, the typical GCC codebase involves traversing and inspecting diverse tree/GIMPLE/RTL nodes, not expecting specific types. The proposed dyn_cast approach, he argues, adds unnecessary verbosity and complexity without significant benefit for these common use cases.
- proposer
Argues the proposed gradual typing introduces 'extra pain' and complexity without clear advantages for the typical ways GCC's internal code is written.
“It is not an improvement, it is extra pain.”
In Details
This exchange continues the debate on integrating gradual typing into GCC's internal representations (GENERIC, GIMPLE, RTL). The core of the disagreement lies in the practical impact of proposed C++ casting mechanisms (like dyn_cast) versus existing macros (TREE_CODE, gimple_code, GET_CODE). Jelinek contends that the common pattern in GCC is to inspect a node's type using macros and then act accordingly, rather than performing a strict type-specific cast. He argues the proposed casts are cumbersome for this pattern, especially when many distinct node types are handled, leading to code…
- tree
- GCC's internal representation of the Abstract Syntax Tree (AST) and other intermediate forms.
- GENERIC
- GCC's highest-level intermediate representation, a typed AST.
- GIMPLE
- GCC's middle-end intermediate representation, a simplified form of the tree AST.
- RTL
- Register Transfer Language, an intermediate representation used in GCC's backend.
- TREE_CODE
- A macro used to determine the type or kind of a GCC tree node.
- dyn_cast
- A C++ RTTI (Run-Time Type Information) mechanism used for safe downcasting, often employed in frameworks like LLVM and proposed here for GCC's tree manipulation.