← Back to context

Comment by fc417fc802

5 days ago

I can't possibly be the first - several other comments here are saying the same thing including the one I was trying to clarify with you.

I don't dislike it per se. I think it's an improvement over not having it but I also think that it's sub-optimal in many scenarios when compared to simply failing the build. Since it's a tradeoff to prevent bugs at the expense of language brevity I don't think it should be surprising that not everyone agrees about it.

My personal preference is the "void" that D has for uninitialized in addition to empty braces or something similarly terse for default initialization.

Slight tangent but somehow C++ ended up with the worst of all possible worlds. Some types uninitialized by default, other types default initialized, terse initialization syntax variants that look highly similar but do different things, and much of it context dependent.

D is consistent in that structs also default initialize:

    struct S { int a; float f; }
    S s;

For C, having an error when the initializer is omitted is better than nothing. However, that is not part of the C Standard, and you'll be relying on having a C compiler with that extension. Otherwise there is undefined behavior. To do it right means it needs to be standardized.