Is this really intended??

claptrap clap at trap.com
Sun Oct 11 09:55:31 UTC 2020


On Sunday, 11 October 2020 at 00:39:54 UTC, Adam D. Ruppe wrote:
> On Sunday, 11 October 2020 at 00:34:57 UTC, Paul Backus wrote:
>> The first assignment to a member inside a constructor is 
>> considered initialization so that you can use constructors to 
>> initialize immutable members:
>
> This isn't what's weird here though, the bizarre thing is it 
> lets you call the method on the "uninitialized" member, then 
> proceed to initialize it afterward.
>
> The rest of it is justified, but that particular aspect is 
> bizarre and I can't justify that...

I though structs were default initialised? I mean I remember 
reading here that one of the design axioms of structs is that 
that have a simple bitblit for initialisation? Is that not done 
for members if their enclosing aggregate has a constructor? If 
you have...

struct Foo { int i; }
struct Bar
{
     Foo foo;
     this() {}
}

Is foo not initialised before entry to Bars constructor? It cant 
be after, so it must be before, or is it not called at all if foo 
is explicitly initialised in Foo.this?




More information about the Digitalmars-d mailing list