http://d.puremagic.com/issues/show_bug.cgi?id=2642
------- Comment #6 from [email protected] 2009-02-21 03:30 ------- One of the solutions is to introduce non-nullable types (both reference and value-types). In this case T.init would be useless (and thus may be safely removed from language*), because user will *have to* initialize it: double d; // compare to "double? d;" which is ok to be non-initialized double dd = 100.0; Same for structs: Foo f; // not initialized (CT-error or write-only until initialized) Foo ff = Foo(); // ok, default-initialized Note that this is very close to classes (same rule - same syntax): Bar b; // not initialized (CT-error or write-only until initialized) Bar bb = new Bar(); // ok, default-initialized As a general rule for all types, T t; // is not an initialized value, a compile-time error is raised, // or just not allowed to be read until initialized (relaxed rule) T t = initializer_expression; // ok, an initialized value -- * I don't mind if T.init will be removed from language specs altogether as I never found it useful. It may still be left for some time in compiler internals (to copy T[] prior to calling T.__ctor), just don't expose it to users. --
