4 ms·
I think you're completely ignoring more radical proposed changes like lambdas: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2738.pdf http://www.open-std.org
by marcodiego 5y ago
I think you're completely ignoring more radical proposed changes like lambdas: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2738.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2738.pdf and more modern error handling: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2361.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2361.pdf
Also consider that proposals must satisfy http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2021.htm http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2021.htm small list of relevant points:
4. Avoid “quiet changes.”
6. Keep the spirit of C.
9. Minimize incompatibilities with C90 (ISO/IEC 9899:1990).
11. Maintain conceptual simplicity.
- dataflow 5y agoI'm not ignoring anything, I just mentioned C++ has had a ton of features over C, some well over a decade (and some just about and some newer). Moreover I can't even see how I could've mentioned lambdas. They have a superfluous keyword? Which one?
- dataflow 5y agoEdit: Whoops, just had a chance to read these comments more carefully. I didn't realize you're talking about C rather than C++. I didn't ignore them; I just wasn't aware of those proposals. (Certainly I haven't seen them on HN, and I don't keep up with all the proposals.)
- huhtenberg 5y agoNot sure if you were trying to make this point, but as others have noted constexpr almost certainly violates #11 (by mixing run-time and compile-time variables) and through that it also violates #6.
- bonzini 5y agoThe two things I would add to C are RAII (like GCC __attribute__((cleanup)) and glib's g_autoptr wrappers), and variant types (mostly so that we could have an equivalent of Rust's Result type).
- enriquto 5y agoRAII is mostly already there, or at least a C-spirited version of it, thanks to variable length arrays. Unfortunately, there's little compiler support for large vla, both clang and gcc seem to choke on them because they put them on the stack (which is the naive implementation of vla).
- bonzini 5y agoHow would variable length arrays, for example, help with releasing a mutex on early returns from a function?
- enriquto 5y agoThey wouldn't, of course! Releasing resources silently (other than the memory of automatic variables) is very un-C-like.
- dataflow 5y ago> RAII is mostly already there >> Releasing resources silently (other than the memory of automatic variables) is very un-C-like The "R" is literally "resource", right? Sounds like instead of RAII you just meant unique_ptr. Though I beg to differ on whether releasing memory automatically is any different from releasing other resources as far as being C-like is concerned!
- bonzini 5y agoIt's not silent, you do declare that you want it released; you just do it before and it applies to all early returns. For example MUTEX_LOCK_GUARD(&lock) for (i = 0; i < n; i++) if (a[i] == x) return i; return -1; Real world example here: https://github.com/qemu/qemu/blob/master/block/iscsi.c#L325 https://github.com/qemu/qemu/blob/master/block/iscsi.c#L325 And the implementation: https://github.com/qemu/qemu/blob/master/include/qemu/lockable.h https://github.com/qemu/qemu/blob/master/include/qemu/lockab... (after inlining, the abstraction is completely zero cost).
- 5y ago