top | item 43732144

(no title)

kbr- | 10 months ago

Yeah it's weird but the author of this post claiming that defer can replace RAII kinda suggests that. RAII isn't just about releasing the resource you acquired in the current scope in the same scope. You can pass the resource across multiple boundaries with move semantics and only at the end when it's no longer needed the resources will be released.

discuss

order

deagle50|10 months ago

I don't get the point, what does this have to do with defer?

kbr-|10 months ago

The author of the post claims that defer eliminates the need for RAII.

Well, goto also eliminates the "need" but language features are about making life easier, and life is much easier with RAII compared to having only defer.