I hate class destructors with a burning passion

Steven Schveighoffer schveiguy at gmail.com
Thu Jun 10 17:53:17 UTC 2021


On 6/10/21 1:09 PM, Kagamin wrote:
> On Thursday, 10 June 2021 at 14:07:04 UTC, Steven Schveighoffer wrote:
>> What about asserts in a related function? The foundation of 
>> programming with functions is that you can abstract common 
>> implementation into another function.
>>
>> I could easily see someone making a helper function for lots of 
>> similar contracts.
> 
> Maybe move all that logic into the precondition of that function?
> 
> void businessFunction(a,b,c) in { checkContract(a,b,c); } {...}
> void checkContract(a,b,c) in { lots of asserts } { empty }

You're not wrong, but it doesn't fix existing code which might not have 
done it that way.

-Steve


More information about the Digitalmars-d mailing list