You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
So something that causes execution to jump to an easily identified place within the same function (goto) is considered "harmful", and something that causes execution to jump to who knows where in the calling hierarchy is "perfectly fine" even for common cases like boring old error handling(!)?Brendan– Brendan2016-05-02 13:53:32 +00:00Commented May 2, 2016 at 13:53
-
1If you think about the scope of the execution it makes sense - throwing an exception immediately terminates the current function. One should take care to design their program structure such that exception handling happens at the most logical place, as if this is not the case, then you do end up with spaghetti-esque code, but given your designs are well structured, exceptions can be very powerful.jasiek.miko– jasiek.miko2016-05-02 14:03:11 +00:00Commented May 2, 2016 at 14:03
-
@Brendan The "who knows where" is part of what makes it good. It's generally bad for a function to know anything about the program outside itself.Kevin Krumwiede– Kevin Krumwiede2016-05-11 01:27:59 +00:00Commented May 11, 2016 at 1:27
-
Using exceptions for errors that are expected to be handles specifically is a mistake (even if it's one promoted by many languages). Exceptions should only be used for the controlled tear-down in case of an unexpected error (typically a bug). Excepted error conditions should be handled by returning the error (typically in a choice-type/tagged-union)CodesInChaos– CodesInChaos2016-05-11 13:22:22 +00:00Commented May 11, 2016 at 13:22
-
I wouldn't say it's necessarily a mistake - some languages offer exceptions and errors to make that distinction. Either way, one should always think carefully about which side of the line their case falls on - whether or should be returned by standard means, or through another mechanism. Whatever the means, if they give a decoupling of "standard" and "exceptional" control flows, you're probably on the right pathjasiek.miko– jasiek.miko2016-05-11 14:46:51 +00:00Commented May 11, 2016 at 14:46
Add a comment
|
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you