[OT] - C++ exceptions are becoming more and more problematic
meta
meta at gmail.com
Thu Feb 24 00:21:12 UTC 2022
On Wednesday, 23 February 2022 at 17:14:53 UTC, H. S. Teoh wrote:
> On Thu, Feb 24, 2022 at 06:02:31AM +1300, rikki cattermole via
> Digitalmars-d wrote:
>> On 24/02/2022 5:59 AM, IGotD- wrote:
>> > The Herb Sutter exception/return value proposal would live
>> > alongside with the old exceptions. I suspect that D would do
>> > the same thing.
>>
>> Yes, with the possibility of having the compiler swap the
>> runtime unwinding stuff for value based where possible.
>>
>> Apart from some situations where you need to be able to store
>> a class based exception, I don't see why it couldn't work like
>> this.
>
> If we had by-value exceptions, we can implement the current
> by-reference exceptions simply by treating the reference to the
> allocated exception as the value to be thrown. I.e.,
>
> throw new Exception(...);
>
> is equivalent to:
>
> struct S {
> Exception e;
> }
> Exception e = new Exception(...);
> throwByValue S(e);
>
> So if we implemented by-value exceptions, we don't have to
> break any existing code, just treat `throw new SomeException`
> as syntactic sugar for some analogue of the above.
>
>
> T
I am sorry but this feels like "hiding my problems under the
carpet" type of solution.. it is not very elegant..
More information about the Digitalmars-d
mailing list