On Tuesday, 14 August 2012 at 21:13:01 UTC, Walter Bright wrote:
On 8/14/2012 3:31 AM, Mehrdad wrote:
Then you get the best of both worlds:

1. You force the programmer to manually initialize the variable in most cases, forcing him to think about the default value. It's almost no trouble for

2. In the cases where it's not possible, the language helps the programmer catch
bugs.


Why the heck D avoids #1, I have no idea.

As I've explained before, user defined types have "default constructors". If builtin types do not, then you've got a barrier to writing generic code.

Just because they _have_ a default constructor doesn't mean the compiler should implicitly _call_ them on your behalf.

C# and Java don't.


It's one of the _major_ features of C# and Java that help promote correctness, and #1 looks orthogonal to #2 to me.

I know Java doesn't have default construction - does C#?


Huh? I think you completely misread my post...
I was talking about "definite assignment", i.e. the _lack_ of automatic initialization.


As for the 'rarity' of the error I mentioned, yes, it is unusual. The trouble is when it creeps unexpectedly into otherwise working code that has been working for a long time.

It's no "trouble" in practice, that's what I'm trying to say. It only looks like "trouble" if you look at it from the C/C++ perspective instead of the C#/Java perspective.

Reply via email to