[OT] - C++ exceptions are becoming more and more problematic

forkit forkit at gmail.com
Thu Feb 24 20:27:50 UTC 2022


On Thursday, 24 February 2022 at 13:36:29 UTC, Mike Parker wrote:
> On Thursday, 24 February 2022 at 13:28:23 UTC, Mike Parker 
> wrote:
>> On Thursday, 24 February 2022 at 13:19:55 UTC, deadalnix wrote:
>>
>>> I don't see what from the discussion here and from the 
>>> original document demonstrate exception to be a bad idea.
>>>
>>
>> I was just responding to forkit's "confusion" about the 
>> contradiction between Walter's current stance and his past 
>> one. I'll leave it to Walter to explain his current thinking, 
>> as I can't recall what he's said about it.
>
> Okay, here we go:
>
> https://www.youtube.com/watch?v=g26eJcs2QB0&t=0s

thanks. for those interested, it's 31 minutes into the talk:

https://youtu.be/g26eJcs2QB0?t=1809

 From what I can grasp, Walter seems not too convinced about 
possible solutions to removing exceptions. His main gripe with 
exceptions seems to be -> "there are a lot of paths in your code 
that you've never thought about".

In any case, when looking at Herbs paper, I'm reminded of what 
Jon Skeet said about exceptions:

" ... in almost every situation where the performance of 
exceptions would be significant, there are bigger design problems 
to worry about."

and..

"When designing the contract of a method, it's worth considering 
whether it's reasonable to call that method in a fairly tight 
loop, continuing to call it even if the previous call fails. In 
that case, it may be worth having two methods, one of which uses 
exceptions to indicate errors and one of which doesn't (like 
Parse and TryParse) but in all other situations, using exceptions 
is unlikely to cause performance problems, but is likely to make 
the calling code much easier to understand.

https://jonskeet.uk/csharp/exceptions.html

Now I don't know too much about exception handling in C++, but 
personally, the above advice has always served me (and my 
end-users) well.

Replacing exceptions with some radical change, will need to be 
well justified, and nobody (as far as I can tell), has done that.




More information about the Digitalmars-d mailing list