DIP1000

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Jun 24 05:11:13 UTC 2022


On Friday, 24 June 2022 at 03:03:52 UTC, Paul Backus wrote:
> On Thursday, 23 June 2022 at 21:34:27 UTC, Ola Fosheim Grøstad 
> wrote:
>> On Thursday, 23 June 2022 at 21:05:57 UTC, ag0aep6g wrote:
>>> It's a weird rule for sure.
>>
>> Another slightly annoying thing is that it cares about 
>> destruction order when there are no destructors.
>>
>> If there are no destructors the lifetime ought to be 
>> considered the same for variables in the same scope.
>
> Having different lifetime rules for different types is worse UX 
> than having the same lifetime rules for all types.
>
> Imagine writing a generic function which passes all of your 
> unit tests, and then fails when you try to use it in real code, 
> because you forgot to test it with a type that has a destructor.

No, the lifetime is the same if there is no destructor. Being 
counter intuitive is poor usability.

If you want to help library authors you issue a warning for 
generic code only.



More information about the Digitalmars-d-learn mailing list