Which D features to emphasize for academic review article
Mehrdad
wfunction at hotmail.com
Tue Aug 14 15:57:23 PDT 2012
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.
More information about the Digitalmars-d
mailing list