Is this really intended??
claptrap
clap at trap.com
Tue Oct 13 22:04:54 UTC 2020
On Sunday, 11 October 2020 at 22:11:48 UTC, Steven Schveighoffer
wrote:
> On 10/11/20 5:50 PM, claptrap wrote:
>> On Sunday, 11 October 2020 at 18:57:55 UTC, Steven
>> Schveighoffer wrote:
>>> On 10/10/20 8:16 PM, claptrap wrote:
>>
>> If there's a question of wasted effort initialising a member
>> twice, the compiler should be able to elide the default
>> initialiser, at least in simple cases the mechanism is already
>> there.
>>
>> They should be separate orthogonal rules.
>
> The default initializer is happening anyway -- the opAssign or
> constructor is expecting it.
I didn't realise the default initialiser and constructor were
separate required events. I thought default initialisation was
enough, the constructors is there if you want something more than
the default init.
I guess that the error message isn't very clear either since it
talks about initialisation when really it's construction that is
needed. I mean if the language is going to differentiate between
initialisation and construction, the error message should be
clear which one is missing.
In fact if the struct has no constructors it can only be default
initialised anyway, so it's seems pointless for the compiler to
require a constructor to be called when it's essentially a NOP.
I mean if the struct has no constructor, then it should be
considered fully constructed after the default init.
More information about the Digitalmars-d
mailing list