On Sun, Dec 11, 2011 at 10:00 AM, Andrei Alexandrescu <[email protected]> wrote: > On 12/11/11 6:05 AM, kenji hara wrote: >> >> 2.057 will compile this code, because it adds the new feature. >> Now null literal has the type that is expressed as typeof(null), not >> void*. >> And typeof(null) is derived from all class types. >> >> static assert(is(typeof(null) : Bob)); // pass in 2.057 >> >> Then IFTI works with null literal correctly. >> >> Kenji Hara > > > This is theoretically correct and practically elegantly realized. Thanks > Kenji! I love how you got this not-so-obvious aspect right. > > The null reference is what's called a "bottom type" in the class type > lattice, i.e. is the opposite of Object, which would be a "top type". Object > is the most general type, the supertype of all classes; typeof(null) is the > most specific type, the subtype of all classes. It is in fact so specific it > can't be instantiated.
And I can confirm that this specific example is working in the beta. Thanks!
