The Ignorability of Attributes in C++
a year ago
- #Attributes
- #C++
- #Language Design
- Attributes in C++ were initially designed to be ignorable, which has led to them being unsuitable for solving many problems.
- The introduction of attributes like [[override]] and [[final]] as contextual keywords instead of attributes has led to inconsistency and complexity in syntax.
- The decision to make attributes ignorable has harmed language evolution, leading to worse decisions and more discussions about self-imposed problems.
- Examples like [[no_unique_address]] show how ignorable attributes can lead to ABI breaks and compatibility issues.
- Current language features, such as trivial relocation in C++26, suffer from being implemented as contextual keywords instead of attributes, leading to more complexity and less expressiveness.
- Future language features could benefit from non-ignorable attributes, but the current model restricts their usefulness.
- The article argues for abandoning the idea of ignorable attributes to stop harming language evolution and to simplify future feature additions.