From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8c87bf30faa2b6b X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: [Q] To initialise or not. Date: 1996/04/26 Message-ID: #1/1 X-Deja-AN: 151571929 references: <484274071wnr@diphi.demon.co.uk> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-04-26T00:00:00+00:00 List-Id: In article <484274071wnr@diphi.demon.co.uk> JP Thornley writes: > ...However the issue of whether or not to require all scalar > objects to be initialised has generated a substantial discussion > without yet reaching a clear conclusion... > Briefly, the argument for initialising everything is > predictability of operation (by avoiding a read of an > uninitialised value). The argument against is that giving > everything an initial value obscures the fact that some objects > *should* be initialised (and the initial value has some > significance) and other initialisations are there simply to follow > the rule (and the value has no particular significance). And if you put in a junk initial value, you override the detection of potentially erroneous uses by the compiler! Compilers can't catch all cases of use of uninitialized variables, but there are several that do pretty well. Require meaningful initial values where possible, and leave it at that. The alternative is to use lots of declare blocks to put meaningful initial values on variables, which can then be declared closer to first use. I have never found this to be a good alternative. Although in Ada it is an occasionally necessary for non-scalars. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...