DIP1000

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


On Friday, 24 June 2022 at 09:08:25 UTC, Dukc wrote:
> On Friday, 24 June 2022 at 05:11:13 UTC, Ola Fosheim Grøstad 
> wrote:
>>
>> No, the lifetime is the same if there is no destructor. Being 
>> counter intuitive is poor usability.
>
> It depends on whether you expect the rules to be smart or 
> simple. Smart is not necessarily better, as the Unix philosophy 
> tells you. I'm sure you have experience about programs that are 
> unpredictable and thus frustating to use because they try to be 
> too smart.

If this feature is meant to be used by application developers and 
not only library authors then it has to match their intuitive 
mental model of life times. I would expect all simple value types 
to have the same lifetime as the scope.

The other option is to somehow instill a mental model in all 
users that simple types like ints also having default destructors.

If it only is for library authors, then it is ok to deviate from 
"intuition".



More information about the Digitalmars-d-learn mailing list