www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - default initializers

reply imr1984 <imr1984_member pathlink.com> writes:
can we have a command line option to turn the code that creates the defautl
initializing of variables OFF? I personally never rely on it - I always
initialize my variables explicitly if I know that they are going to be read from
right away; and I worry that this implicit initialization would be inneficient
Apr 08 2005
next sibling parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

imr1984 schrieb am Fri, 8 Apr 2005 08:45:21 +0000 (UTC):
 can we have a command line option to turn the code that creates the defautl
 initializing of variables OFF? I personally never rely on it - I always
 initialize my variables explicitly if I know that they are going to be read
from
 right away; and I worry that this implicit initialization would be inneficient

Maybe support for "-Wuninitialized" and correct dataflow analysis in the compiler to remove unrequired initialization is better. (1) from: # int i; # i = 2; (1) to: # int i = 2; (2) from: # char[2] arr; # char[0]='a'; # char[1]='b'; (2) to: # int[2] arr = ['a', 'b']; TODO: * can turn out quite compilcated for some flowcharts - e.g. Object initializers * requires additon of _d_new... without the use of memset to the GC Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCVkuu3w+/yD4P9tIRAmVuAJsEPS/sqoTZxv5TYsRLXPfAB1s/xQCeLXwn 4Zxr2YNTzt7IHeugq53oS0I= =mVzl -----END PGP SIGNATURE-----
Apr 08 2005
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"imr1984" <imr1984_member pathlink.com> wrote in message
news:d35gb1$1uhf$1 digitaldaemon.com...
 can we have a command line option to turn the code that creates the

 initializing of variables OFF? I personally never rely on it - I always
 initialize my variables explicitly if I know that they are going to be

 right away; and I worry that this implicit initialization would be

The optimizer will eliminate most redundant initializations, so there shouldn't be much of any efficiency problem.
Apr 08 2005