3 ms·
You should take a closer look at zig. While superficially the syntax is very different, what zig really is, c but more specific
by pyrolistical 2y ago
You should take a closer look at zig. While superficially the syntax is very different, what zig really is, c but more specific
- lisper 2y agoNo, I get that. I was referring to the syntax. Syntax matters. Zig is hands-down a better language than C, and (I'll take your word that) it fills the same niche as C, but it is still a different language with its own idioms and lore and conventions. It is not C-with-tweaks. It cannot be compiled by an extant C compiler. Code written under my proposal would be legal C code under the current standard (but not the other way around). [EDIT] Actually, that turns out not to be true. You'd need to change the behavior of SIZEOF or provide some other way of getting the size of dynamically allocated arrays at run time, since this information would now be maintained by the compiler.
- unwind 2y agoOf course sizeof already has that capability since C has variable length arrays. They are kind of being phased out, but they are there. You can do this: #include <stdio.h> int main(int argc, char *argv[]) { unsigned int lens[argc]; for (int i = 0; i < argc; ++i) lens[i] = (int) strlen(argv[i]); printf("Computed %d lens into %zu bytes of array\n", argc, sizeof lens); return 0; } Very contrived pointless example, but still.