From: david.brown@hesbynett.no   
      
   On 29/11/2025 20:36, Waldek Hebisch wrote:   
   > David Brown wrote:   
      
   >> _BitInt's are not arrays, they are scalars - they are integer types.   
   >> There is no concept of a type "_BitInt" - they always have compile-time   
   >> fixed sizes, such as "_BitInt(12)". So the idea of passing around   
   >> generic _BitInt's makes no more sense than passing around any other kind   
   >> of generic integer types. (Of course you can have an array of _BitInt's   
   >> of any given size.)   
   >   
   > There are languages which pass generic types, but C is not one   
   > of them. So idea of passing around generic _BitInt's makes sense,   
   > but this is not included in C.   
   >   
      
   By "pass around generic types", do you mean that you can write a   
   function that handles different types in the same parameter spot, and   
   have the function do different things for different passed-in types? C   
   has at least three ways to handle such things :   
      
   1. Variadic functions and the macros. "printf" is a prime   
   example of a function that can take parameters of many different types.   
      
   2. Passing arbitrary data via "void *" pointers. People do it all the time.   
      
   3. _Generic macros. These are not functions, but can pass off control   
   to different type-specific functions depending on the type of the arguments.   
      
      
   You can use any of these methods with _BitInts, but they are all missing   
   something significant in comparison to the support you would (and I   
   expect will) get in C++ with a template-based std::bit_int, or in   
   higher level languages like Python (if it had an equivalent of a set of   
   _BitInt types).   
      
   I therefore expect to be able to do more interesting things with _BitInt   
   types in C++ than in C, and do so in much simpler ways than equivalents   
   in C.   
      
   My point was that to do "something with generic _BitInt's" you have to   
   have to deal with a range of types, not one type with a range of sizes   
   or bit-counts.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|