On 30.08.2011 0:22, Walter Bright wrote:
For the latest dmd,
https://github.com/D-Programming-Language/dmd/commit/1193f7828b444056c943742daae0a5ccf262272e
,
I've implemented the ability to disable default initialization. This
makes it practical to implement a library based "NotNull" type without a
special syntax for it. The rationale for this is (rather than making it
builtin) one can now build any type that is a restricted subset of
another type. I suspect that a non-null type is just scratching the
surface of this ability.
Nice!
Clean RAII with structs comes to mind, before you'd have to have .init
to be as an invalid state that is always checked later on, e.g.:
File f;
f.write("blah");//will fail enforce inside write
I suspect it can get a bit tricky to deal with arrays of such types though.
--
Dmitry Olshansky