4 ms·
I might like to have, in a better version of C: - GNU extensions, such as zero-length arrays, ?: with nothing in between, and statements inside of expressions
by zzo38computer 6y ago
I might like to have, in a better version of C:
- GNU extensions, such as zero-length arrays, ?: with nothing in between, and statements inside of expressions
- Less confusing syntax for types
- Full LLVM features
- Non-Unicode
- Both normal include files and token macros, as well as namespacing and hygienic macros supported too
- Standard macros for testing alignment, endianness, etc
- Macros that can call compile-time execution of codes which can deal with the AST
- Reduced runtime requirements
- Support for setjmp/longjmp with catch blocks; if you longjmp past such a block, it should execute the catch block to clean up as needed before that block jumps again back to the target of the longjmp operation
- The goto command.
The worst thing about C is I think the confusing syntax for types. Pointer arithmetic and goto are both good, though, so keep those.
I can do without automatic memory management.
- Nuoji 6y ago- Some GNU extensions are already there, let me know what else you need. - ?: and statement expressions (slightly extended) are available in C3 today. - Type syntax is simplified in C3 more in line with other languages, e.g. java style array declarations. - What does "full LLVM features" mean? - What do you mean by "Non-Unicode"? - You'll likely be able to include files (and more), but token macros are out I'm afraid. I've tried to cover all uses, but I know it's not quite complete :( - All the stuff with offset, alignment etc will of course be available. - Macros can act like compile time functions, but direct manipulation of the AST is not there to make the macros easier and safer to use. There is stil a lot of things one can do with using conditional compilation etc, but no manual construction of AST nodes. It's about trying to keep the language fairly uniform even though you add a very powerful macro system. I'm sorry. - What do you mean by "reduced runtime requirements"? The ability to run it freestanding? If so, yes then this is a goal. - No setjmp/longjmp, instead it has a system with implicit "Result" style returns. But it has a unique flavour. A brief overview can be found here: http://www.c3-lang.org/errorhandling/ http://www.c3-lang.org/errorhandling/ - Sadly I had to give up on goto. To replace it: labelled blocks and labelled for/do/while/if, switch-jumps with "next", error handling using "failable" Result types and defer. The reason for removing goto was due to the amount of compiler complexity needed to support unstructured jumps. I didn't remove it willingly.