char[] initialization

Carlos Santander csantander619 at gmail.com
Sat Jul 29 14:00:52 PDT 2006


Hasan Aljudy escribió:
> 
> 
> Still missing my point.
> in C/C++ that's a problem because un-initialized variables carry garbage.
> in D, it's not; if you init them to a reasonable valid default, this 
> problem won't exist anymore.
> 
> If un-initializing is bad just for its own sake .. then the compiler 
> should detect it and issue an error/warning, otherwise it should default 
> to a reasonable valid value; in this case, zero for chars and floats.

The issue here is, a "reasonable valid default" will change from one app to the 
other, one function to the next, one variable to another, so the intention here 
is force the developer to be explicit about his/her intentions.

Walter has said in the past that if there was a NAN for int/long/etc, he'd use 
that instead of 0.

-- 
Carlos Santander Bernal



More information about the Digitalmars-d mailing list