3 ms·
Yep, talking about C here, not C++. If they would add that feature, you could use macros to get constructor and destructor like behavior (as long as it's withi
by Aardwolf 8y ago
Yep, talking about C here, not C++.
If they would add that feature, you could use macros to get constructor and destructor like behavior (as long as it's within the same scope, you could write a macro that constructs your object, and in addition contains something like "at scope exit: run this function"), which would be super useful and as far as I'm aware not very complex for the compiler (as all they have to do is run some code whenever exiting scope) nor very far outside of the spirit of C (it's still very low level, just a small convenience feature with interesting implications, especially when used with macros).
- kazinator 8y agoC++ is a dialect of C. It is the result of starting with C, and then accommodating a massive, sustained sequence of feature requests, exactly like ones we are seeing in this thread. Everyone thinks that if just their pet feature request is added to C and everyone else's ideas are rejected, it will still be C.
- bunderbunder 8y agoC++ is more than that; it's a set of additional features that create something of a C-flavored multiparadigm language. Which inevitably does turn it into a kitchen sink language, since it's trying to be all things to all people. This idea doesn't seem to be in that spirit to me. It's not trying to do something radical like, say, adding OOP semantics to C. It's suggesting that C, a structured programming language, get a feature designed to improve the ergonomics for people doing structured programming in C.