February 24, 2022
On Thursday, 24 February 2022 at 08:08:49 UTC, Paulo Pinto wrote:
>
> They aren't going anywhere, most of Herb's latest papers seem like ideas how the language could be improved upon, but beyond the original paper, presentation at CppCon and eventually some prototype available on Compiler Explorer, little more has happened.
>
> I might be wrong here, but from C++ mailings it is clear nothing is happening with those papers.
>
> Also in regards to exceptions, Bjarne has a paper where he criticizes the current compiler implementations for leaving performance improvements on the table by not wanting to break existing ABIs, while arguing against Herb's approach.
>
> "C++ exceptions and alternatives"
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1947r0.pdf

That's a problem for D because I suggest that we copy whatever C++ decides to implement. The reason is that the solution is probably going to be good enough for D. Using the C++ solution also ensures FFI compatibility. Associated with the new C++ error handling is going to be an ABI change (for every CPU architecture) and that the D project would create its own bespoke ABI is a lot of work which might not play well with C++ or other SW.

February 24, 2022
On Thursday, 24 February 2022 at 00:19:44 UTC, meta wrote:
>> Support struct based exceptions (value type), passed on stack (and hence RC support) as part of the return value of a function.
>
>
> Who will allocates that (the RC part)?
>
> I personally disagree with the idea of exceptions altogether..
>
>
> The answer is in solutions like in Zig/Go, errors, multiple return values, if changing the way error handling works in D, better make it good, for good!

oh god, go code is so stupid to read b/c theres error handling everywhere mixed with code logic. i'm all for adding multiple return values, aka tuples, but exceptions are by far the best error handling method by readability. also you are forced to catch them and you got stack traces, which is super useful.


Zot
February 24, 2022
On Thursday, 24 February 2022 at 10:06:24 UTC, IGotD- wrote:
> On Thursday, 24 February 2022 at 08:08:49 UTC, Paulo Pinto wrote:
>>
>> They aren't going anywhere, most of Herb's latest papers seem like ideas how the language could be improved upon, but beyond the original paper, presentation at CppCon and eventually some prototype available on Compiler Explorer, little more has happened.
>>
>> I might be wrong here, but from C++ mailings it is clear nothing is happening with those papers.
>>
>> Also in regards to exceptions, Bjarne has a paper where he criticizes the current compiler implementations for leaving performance improvements on the table by not wanting to break existing ABIs, while arguing against Herb's approach.
>>
>> "C++ exceptions and alternatives"
>>
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1947r0.pdf
>
> That's a problem for D because I suggest that we copy whatever C++ decides to implement. The reason is that the solution is probably going to be good enough for D. Using the C++ solution also ensures FFI compatibility. Associated with the new C++ error handling is going to be an ABI change (for every CPU architecture) and that the D project would create its own bespoke ABI is a lot of work which might not play well with C++ or other SW.

Until ISO C++26, ISO C++ is definitly not deciding anything related to Herb's proposal, and it remains to be seen if there will be anything in a form of a proper ISO C++ feature proposal paper for post ISO C++26.

Waiting for C++ to decide anything is only detrimental for D.
February 25, 2022
On 24/02/2022 9:42 PM, Alexandru Ermicioi wrote:
> So why not have this implemented as underlying mechanism for existing try catch syntax, with option to choose which one to use?
> 
> If done so, there shouldn't be any usability downgrade, when selecting either existing or new exception mechanism, only distribution of performance overhead will change.

My concern is that there will be situations which no one can predict; exceptions are very hairy (after all, they can go up the chain of functions not written in D).

This is why I'm not suggesting that we should replace exception handling in the general case. Only where the compiler can see that it can be done (plus this can be improved over time).
February 24, 2022
On Thursday, 24 February 2022 at 11:07:31 UTC, rikki cattermole wrote:
>
> My concern is that there will be situations which no one can predict; exceptions are very hairy (after all, they can go up the chain of functions not written in D).
>
> This is why I'm not suggesting that we should replace exception handling in the general case. Only where the compiler can see that it can be done (plus this can be improved over time).

I think that exceptions work kind of well in a code cleanness kind of way. The proposal from Herb Sutter looks like exceptions but it is return values under the hood.

D also has the ingenious scope guards (scope(exit) and such) which work very well with exceptions. It would be bad if this would be thrown away with a new error handling mechanism. Therefore I think return values should also have the exception syntax.
February 25, 2022
On 25/02/2022 12:22 AM, IGotD- wrote:
> D also has the ingenious scope guards (scope(exit) and such) which work very well with exceptions. It would be bad if this would be thrown away with a new error handling mechanism. Therefore I think return values should also have the exception syntax.

Agreed, I didn't write it in my proposal earlier because nothing syntax wise would change for how you would use it.

The only difference is the @throws attribute as far as users are concerned and that has benefits by itself.
February 24, 2022

On Thursday, 24 February 2022 at 08:05:42 UTC, forkit wrote:

>

That is, how do I reconcile your above statement with your previous statement:

"Why exceptions for error handling is so important" - Walter Bright.

The fact that D has had exceptions from the beginning shows he thought they were a good idea before. Opinions evolve over time.

February 24, 2022

On Thursday, 24 February 2022 at 12:33:04 UTC, Mike Parker wrote:

>

On Thursday, 24 February 2022 at 08:05:42 UTC, forkit wrote:

>

That is, how do I reconcile your above statement with your previous statement:

"Why exceptions for error handling is so important" - Walter Bright.

The fact that D has had exceptions from the beginning shows he thought they were a good idea before. Opinions evolve over time.

I don't see what from the discussion here and from the original document demonstrate exception to be a bad idea.

In fact, in the benchmark they propose, all alternative solution are slower in the fast path. The tradeof that is proposed by exceptions is the following: have as little impact as possible on the fast path, at the cost of making the exceptional path significantly slower.

This is a worthy tradeof.

And when I'm saying getting out of the way, I'm not talking exclusively run time, but also for the developer: there is no need to litter the code with numerous exception handling path all over the place.

I'm not sure I understand why C++ exception need to take a lock. What have they done this time to deserve this?

February 24, 2022

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.

February 24, 2022

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