null [re: spec#]

Simen kjaeraas simen.kjaras at gmail.com
Tue Nov 9 02:22:31 PST 2010


Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> We definitely want to avoid the nastier issues, but the lack of default
> constructors continually pops up as being a major problem. The QtD folks  
> in
> particular were have a lot of problems because of it as I understand.  
> I've
> certainly had problems with it my code. Even a restricted default  
> constructor
> would be better than none.

In my experience, disabling the default constructor would be enough.
That way the compiler warns you that 'this object has no valid default
state, so use a constructor.'


> If we could have default constructors on structs but have it so that any  
> struct
> with a default constructor cannot be used where you have to have a bare  
> init
> with no constructor call

And where is that? Currently no such thing exists, as we have no default
constructors for structs. That means we could interpret any use of .init
as a constructor call. Disabling default constructors has this same
advantage, while avoiding the problems. The only problem is you will have
to use a constructor explicitly.

-- 
Simen


More information about the Digitalmars-d mailing list