C# interview
Denis Koroskin
2korden at gmail.com
Thu Oct 2 05:09:08 PDT 2008
The two things that needs to be changed to support this feature are:
1) make typeof(null) == void*
2) remove default initializers (for reference types, at least)
The latter rule can be relaxed (as done in C#): you can have a variable
uninitialized. However, you can't read from it until you initialize it
explicitly. This is enforced statically:
// The following is ok:
Object o;
o = new Object();
// This one is ok, too:
Object o;
if (condition) {
o = new Foo();
} else {
o = new Bar();
}
// But this is rejected:
Object o;
if (condition) {
o = new Foo();
}
Object o2 = o; // use of (possibly) uninitialized variable
More information about the Digitalmars-d
mailing list