Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
lealanko
3 months ago
|
parent
|
context
|
favorite
| on:
Problems with C++ exceptions
This is a common problem with try-catch syntax. An alternative, and arguably more useful syntax would be
try (File_handle fh {s, "r"}) { // use fh } unless (const File_error& e) { // handle error }
Where the "use fh" part is
not
covered by the exception handler. This is covered (in ML context) in
https://www.microsoft.com/en-us/research/publication/excepti...
mgaunard
3 months ago
[–]
Don't use try/catch in the first place; that's where his error lies.
1718627440
3 months ago
|
parent
[–]
That's not his own invention, but an idea introduced by the language founder to sell the idea of RAII and exceptions. He did say, that he would prefer the C version, but then why use C++ in the first place.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: