Hacker News new | ask | show | jobs
by iainmerrick 2930 days ago
Exceptions are part of the reason that RAII is so critical in the C++ world.

I don’t think that’s quite true. You definitely want RAII with exceptions, yes, but RAII is extremely useful even without exceptions. I believe it’s common to disable C++ exceptions but still use RAII.

If you have multiple returns from a function (which can very easily happen with manual error checking) RAII is a big win.

1 comments

> You definitely want RAII with exceptions, yes, but RAII is extremely useful even without exceptions.

Which is another way of saying exceptions are part of the reason for RAII.

Yesssss, but, I still think that’s misleading. It’s like saying ATMs are part of the reason for cash.