On Tuesday, 14 August 2012 at 21:58:20 UTC, Walter Bright wrote:
On 8/14/2012 2:22 PM, Mehrdad wrote:
I was talking about "definite assignment", i.e. the _lack_ of automatic initialization.

I know. How does that fit in with default construction?

They aren't called unless the user calls them.


        void Bar<T>(T value) { }
        
        void Foo<T>()
                where T : new()   // generic constraint for default constructor
        {
                T uninitialized;
                T initialized = new T();
        
                Bar(initialized);  // error
                Bar(uninitialized);  // OK
        }
        
        void Test() { Foo<int>(); Foo<Object>(); }


D could take a similar approach.

Reply via email to