Improving _Generic in C2y
The C programming community is enhancing the _Generic feature for the C2y standard to resolve issues from C23, focusing on simplifying type matching and addressing limitations in usability and behavior.
Read original articleThe C programming community is currently working on improvements to the _Generic feature as part of the C2y standard, following the completion of C23. The aim is to address issues that arose during previous standardization cycles, particularly the long delays between bug fixes and releases that hindered contributions. _Generic, introduced in C11, allows for type-based behavior by matching expressions to types, but it has faced criticism for its complexity and limitations, particularly regarding l-value conversion, which can strip qualifiers from types.
Two main problems with _Generic have been identified: the need for l-value conversion complicates type matching, and the feature only accepts expressions, which limits its usability. To address these issues, a proposal (N3260) was introduced to allow type names in place of expressions, enabling direct type matching without the complications of l-value conversion. This change has been implemented in Clang and is expected to be adopted by GCC.
While the new implementation simplifies the use of _Generic, it may introduce confusion in certain scenarios, particularly regarding type matching with expressions. Further refinements are anticipated to enhance compatibility and address undefined behaviors associated with variable-length arrays. Overall, these developments represent a significant step forward in improving the usability and functionality of _Generic in C programming.
Related
The C Standard charter was updated, now with security principles as well
The ISO/IEC JTC1/SC22/WG14 committee oversees C Standard development, focusing on portability, efficiency, and stability. Collaboration with the C++ committee ensures compatibility. Principles guide feature integration, code efficiency, security, and adaptability.
Reflection for C++26
The P2996R4 document proposes a reduced set of static reflection features in C++26, using constant expressions, a reflection operator, metafunctions, and splicers. Implementation progress is ongoing by Lock3 and EDG.
Zig-style generics are not well-suited for most languages
Zig-style generics, inspired by C++, are critiqued for limited universality. Zig's simplicity contrasts with Rust and Go's constraints. Metaprogramming praised for accessibility, but error messages and compiler support pose challenges. Limited type inference compared to Swift and Rust.
New Features in C++26
The ISO released new C++ standards on a three-year cycle, with C++26 proposals open until January 2025. Updates include hazard pointers, user-space RCU support, debugging headers, and template enhancements for improved functionality.
C Isn't a Programming Language Anymore (2022)
The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.
There is a third: the discarded branches must typecheck. (Unlike C++ templates, where substitution failure is not an error.) Simon Tatham described the issue in more detail:
https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/c11-g...
Move fast!
Related
The C Standard charter was updated, now with security principles as well
The ISO/IEC JTC1/SC22/WG14 committee oversees C Standard development, focusing on portability, efficiency, and stability. Collaboration with the C++ committee ensures compatibility. Principles guide feature integration, code efficiency, security, and adaptability.
Reflection for C++26
The P2996R4 document proposes a reduced set of static reflection features in C++26, using constant expressions, a reflection operator, metafunctions, and splicers. Implementation progress is ongoing by Lock3 and EDG.
Zig-style generics are not well-suited for most languages
Zig-style generics, inspired by C++, are critiqued for limited universality. Zig's simplicity contrasts with Rust and Go's constraints. Metaprogramming praised for accessibility, but error messages and compiler support pose challenges. Limited type inference compared to Swift and Rust.
New Features in C++26
The ISO released new C++ standards on a three-year cycle, with C++26 proposals open until January 2025. Updates include hazard pointers, user-space RCU support, debugging headers, and template enhancements for improved functionality.
C Isn't a Programming Language Anymore (2022)
The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.