Compile-time reference type objects construction (Was - Re: struct

Kagamin spam at here.lot
Tue Dec 23 01:47:46 PST 2008


Denis Koroskin Wrote:

> I don't agree with you. If so, then why we have the following syntax allowed:
> 
> class Foo
> {
>     int i = 42;
> }

It fits well into .init feature. If you want to split constructor, some subtle bugs can arise. For example one programmer stumbled into such bug in Java: base class constructor was called, it called virtual method, overriden in derived class, this method assigned an object to a field, then base class constructor returned and derived field initializers were called and they assigned null to that field, so object ended up with null in the field.


More information about the Digitalmars-d-learn mailing list