3 ms·
Tagged unions? -- please no... I could be convinced to completely lose unions in C, though (pointer to member or base of struct can be cast to another struct an
by ratboy666 9y ago
Tagged unions? -- please no... I could be convinced to completely lose unions in C, though (pointer to member or base of struct can be cast to another struct anyway, so losing unions doesn't gain anything; for the same reason tagged unions just would not be useful)
Boolean type? Sure, but that would be dependent on use. What is wrong with a bitfield one bit wide instead? What may be useful is "packed bitfield" type ("packed" in Pascal). Then, array of packed bit could be expressed.
Multiple return types - yes, "return a b;" (or something would be nice.
Lack of polymorphism - reference "void *" The main problem is that calls cannot be constructed in C (that is, the standard does not have a "C to C" FFI.
Anyway, just food for thought.
- benlorenzetti 9y agoUnions would be nice if the syntax for accessing substructure members could be nominally short circuited. For example: struct ab { int a; int b; }; union c { struct ab ab_short_circuit; int a; }; union c c1; c1.a = 1; c1.b = 2;
- cesarb 9y agoThat already exists, as a Microsoft extension, and if the struct is declared within the union, in standard C: https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Unnamed-Fields.html https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Unnamed-Fields.... (However, in your example, c1.a is ambiguous, so it won't compile.)
- benlorenzetti 9y agoI did not realize this as a Linux user--thanks. (But this is my point, it is should not be ambiguous.)