I hate class destructors with a burning passion

FeepingCreature feepingcreature at gmail.com
Thu Jun 10 13:09:36 UTC 2021


On Thursday, 10 June 2021 at 12:59:59 UTC, Steven Schveighoffer 
wrote:
> On 6/10/21 8:07 AM, Kagamin wrote:
>> On Wednesday, 9 June 2021 at 17:54:06 UTC, Timon Gehr wrote:
>>> On 09.06.21 04:37, Walter Bright wrote:
>>>>
>>>> Allocating via the GC is in assert is just ridiculous, as 
>>>> the program is going to exit shortly anyway. There won't 
>>>> ever be a need to run a collection on it. Just malloc away 
>>>> and fuggeddabootet.
>>>
>>> AssertError is still *caught* /by the language/ on in 
>>> contract inheritance.
>> 
>> I'd say, lower assert failures in contracts to a different 
>> function, say, _d_contractFailed(), which can do a different 
>> thing, say, throw ContractError, and child contract can catch 
>> only this specific ContractError instead of any Error.
>
> What about asserts in functions called by the contract? I guess 
> technically they are not part of the contract, just poor 
> coding, but people may rely on those asserts in some cases.
>
> -Steve

All the more reason to throw `ContractError` instead of 
`AssertError`. Asserts in an unrelated function should not be 
caught as part of in-condition processing.


More information about the Digitalmars-d mailing list