Error: constant false is not an lvalue
Don
nospam at nospam.com
Mon Aug 31 02:46:59 PDT 2009
Rainer Deyke wrote:
> Jarrett Billingsley wrote:
>> "Members are always initialized to the default initializer for their
>> type, which is usually 0 for integer types and NAN for floating point
>> types. This eliminates an entire class of obscure problems that come
>> from neglecting to initialize a member in one of the constructors."
>> http://www.digitalmars.com/d/1.0/class.html
>>
>> This suggests, to me, that default initialization _is_ - at least in
>> Walter's mind - supposed to eliminate bugs.
>
> You (and possibly Walter) are comparing default initialization to
> uninitialized variables, which is a false dichotomy. I'm comparing
> default initialization to explicit initialization.
The whole point is to avoid uninitialized variables. Ideally, this would
be done with explicit initialisation.
The problem is that explicit initialisation is very painful to enforce.
You can, however, enforce default initialisation -- it sometimes causes
inefficiency, but it doesn't hurt the programmer much. And the =void
allows you to avoid the efficiency hit, for the rare occassions when it
matters.
Default initialisation is a poor man's explicit initialisation.
More information about the Digitalmars-d-learn
mailing list