On Tuesday, 14 August 2012 at 10:31:30 UTC, Mehrdad wrote:
Note to Walter:
You're obviously correct that you can make an arbitrarily
complex program to make it too difficult for the compiler to
enforce initialization, the way C# does (and gives up in some
cases).
What you seem to be missing is that the issue you're saying is
correct in theory, but too much of a corner case in practice.
C#/Java programmers ___rarely___ run into the sort of issue
you're mentioning, and even when they do, they don't have
nearly as much of a problem with fixing it as you seem to think.
Completely agree. I find it quite useful in C#. It helps a lot in
hairy code (nested if/foreach/try) to make sure all cases are
handled when initializing variable. Compilation errors can be
simply dismissed by assigning a 'default' value to variable at
the beginning the functions, but is generally a sloppy programing
and you loose useful help of the compiler.
The rules in C# are very simple and almost verbatim can be
applied to D
http://msdn.microsoft.com/en-us/library/aa691172%28v=vs.71%29.aspx