comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: [Q] To initialise or not.
Date: 1996/04/26
Date: 1996-04-26T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.96Apr26141208@spectre.mitre.org> (raw)
In-Reply-To: 484274071wnr@diphi.demon.co.uk


In article <484274071wnr@diphi.demon.co.uk> JP Thornley <jpt@diphi.demon.co.uk> 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...




  parent reply	other threads:[~1996-04-26  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-25  0:00 [Q] To initialise or not JP Thornley
1996-04-26  0:00 ` Theodore E. Dennison
1996-04-26  0:00   ` Robert A Duff
1996-04-27  0:00     ` Thorsten Behrens
1996-04-28  0:00       ` Robert Dewar
1996-04-30  0:00       ` mjp
1996-05-02  0:00       ` Bob Gilbert
1996-04-26  0:00 ` Ken Garlington
1996-04-26  0:00 ` Robert I. Eachus [this message]
1996-04-26  0:00 ` Ken Garlington
1996-04-26  0:00   ` Robert A Duff
1996-04-27  0:00   ` Robert Dewar
1996-04-27  0:00     ` Robert A Duff
1996-04-27  0:00 ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox