comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Initialization
Date: 14 Jun 90 16:37:48 GMT	[thread overview]
Message-ID: <1957@sparko.gwu.edu> (raw)

I have a rationale-type questions regarding an apparent irregularity
in Ada, namely in the area of default initializations.

- We know that a _variable_ can be initialized in its declaration, e.g.
   X: T := some_expression;
where some_expression need not even be static. [digression: over-use of
this can be risky IMHO because of nastiness if some_expression manages to
propagate an exception - the point is that initialization is permitted].

- We know that the components of a _record_ type can be default-initialized
in the definition of the record type, e.g.
   type R is record
     F1 : T1 := something;
     F2 : T2 := something_else;
   end record;
where some thing something_else can be e.g. aggregates.

I don't remember having seen any discussion on the group about why other
types cannot be default-initialized, e.g.
   type Little is range -10 .. 10 := 0;
or
   type Vector is array (1..10) of float := (1..10 => 0.0);
or even
   type Vector is array (integer range <>) of float := (others => 0.0);

The last 3 examples are not permitted; it's obvious at least to me that
there would be great benefit in permitting them. What are the costs?

Can someone speak authoritatively about why this irregularity exists? The
Ada Rationale gives a nice justification of default initializations (for
record types, of course) but doesn't say boo about why, if they are so
valuable, they are not allowed uniformly. I'm one of these guys who always
wonders why irregularities in _designed_ languages exist. There is usually
a pretty good reason, but in this case it certainly isn't obvious.
(Irregularities even in natural languages often have good linguistic reasons).

Thanks for whatever enlightenment is forthcoming.
---------------------------------------------------------------------------
Prof. Michael Feldman
Department of Electrical Engineering and Computer Science
The George Washington University
Washington, DC 20052
+1-202-994-5253
mfeldman@seas.gwu.edu
---------------------------------------------------------------------------

             reply	other threads:[~1990-06-14 16:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-06-14 16:37 Michael Feldman [this message]
1990-06-14 17:38 ` Initialization Robert Firth
1990-06-14 22:28   ` Initialization Michael Feldman
1990-06-14 19:37 ` Initialization Mike Murphy
1990-06-14 22:43   ` Initialization Michael Feldman
  -- strict thread matches above, loose matches on Subject: below --
1991-03-24 21:23 Pre-condition vs. Post-condition stt
1991-03-25 16:00 ` Arthur Evans
1991-03-25 17:05   ` Michael Feldman
1991-03-26  4:31     ` Jim Showalter
1991-03-26 10:21       ` Richard A. O'Keefe
1991-03-27 21:32         ` Initialization Paul Stachour
replies disabled

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