Hacker News new | past | comments | ask | show | jobs | submit login

The statement that jumping to an error handler evolved into modern exceptions (2.4) is a bit misleading. Exceptions as we know them today have three properties.

(1) The target is not necessarily known at compile time.

(2) The catcher is likely not the same function as the thrower, with several other functions in between.

(3) The stack is unwound as part of the throw/catch, including things like destructors.

Even the uber-powerful "goto" that Dijkstra railed against didn't have these properties, let alone the tamer "goto" of modern languages like C. Personally I think (1) and (2) are reasons why exceptions are far worse than gotos, but if you're going to have them then you'd best have (3) as well. What I always find strange is people who look down their noses at code with gotos carefully used for error cleanup, but have no qualms about flinging exceptions around in their own code. I guess those who do not learn the lessons of history, etc.




As I recall, my goal was merely to point out that unstructured jumps are still used for error handling. I was in no way attempting to claim that the two features are the same.

I'm sorry for any confusion.


No need to apologize. I didn't mean to suggest any failure of intent or diligence. The problem is only that people who have grown up in a culture of both "goto is evil" and "exceptions are free" has a poor lens through which to view the comparison. It's just one of those things that might need to be clarified in a later version as time marches on around us. In general, I found the article very well written and helpful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: