Skip to main content

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.

4
  • 1
    If code is trying to parse an integer which is going to be valid unless an input file is sufficiently corrupted as to render any attempts at parsing meaningless, there's really not much benefit to having the parser's immediate calling code try to handle a parse fail gracefully. Unfortunately, existing languages' exception mechanisms are poorly adapted to distinguish between scenarios where a function fails without adverse side effects, and those where failure could leave an object in a corrupted state. Proper Dispose handling for things like lock tokens should distinguish between... Commented Feb 12, 2020 at 23:21
  • ...cases where code that uses a token completes normally (implying the lock should be released) and cases where it exits via an exception (implying that if the token was acquired for writing, the lock should be invalidated such that all pending and future acquisition attempts fail instantly). Unfortunately, without a provision for that, distinguishing between recoverable and unrecoverable failures will be very difficult. Commented Feb 12, 2020 at 23:24
  • @supercat - Files being unreadable (whether due to byte twiddling or just a wrong text block) is an anticipable error. If that means your application can't process that file any further, then don't do so (or stop the program). Otherwise, if you're trying to lock the file such that other programs can't read it, that's usually poor behavior. Commented Feb 12, 2020 at 23:56
  • @Clockwork-Muse it may be worth using the words checked and unchecked in your answer Commented Feb 20, 2020 at 7:23