Re:A Defer Mechanism for C
by rcxdude on Tuesday December 15, 2020 @07:33AM
(#25429672)
It's the other way around. Defer is only capable of dealing with the surface level of RAII: creating and destroying something which only exists on the stack for a defined period. RAII is much more, it deals with the full lifetime of the object, including objects with dynamically defined lifetimes, and the lifetime of objects which are members of other objects. And you can implement defer with RAII very easily, with zero overhead, in C++. (there's a similar misconception which holds that features in garbage collected languages like try-with-resources, with, or using statements are a complete replacement for RAII, when they have the same problems.)
[ Parent
| on HN ]
There are no comments on this comment yet.