Re:Why Not Just Do Simple C++ RAII in C?
by quietbritishjim on Wednesday May 22, 2024 @04:37PM
(#40446184)
The difference is that in C++ it's expected that you'll overload operators, provide implicit conversions and throw exceptions. Of course you can write terrible code in C but it is not common accepted practice to hide a longjmp in a macro disguised as an identifier.
[ Parent
| on HN ]
Re:Why Not Just Do Simple C++ RAII in C?
by jay-barronville on Wednesday May 22, 2024 @04:55PM
(#40446421)
The funny thing is, examples of macro craziness only strengthen my point, because C++ inherits all of that in addition to its hidden behaviors and magical semantics. It’s rare to find serious C code doing a lot of crazy things behind macros. In my experience, the few exceptions I can think of include the GMP library and data structure-related code trying to emulate generics (mostly hash tables).
Re:Why Not Just Do Simple C++ RAII in C?
by gpderetta on Wednesday May 22, 2024 @05:13PM
(#40446627)
Yes, C++ is a larger language for sure. But because it has better abstraction facilities, macro hackery is less common.