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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Initialization Message-ID: <1957@sparko.gwu.edu> Date: 14 Jun 90 16:37:48 GMT Reply-To: mfeldman@seas.gwu.edu (Michael Feldman) Organization: The George Washington University, Washington D.C. List-Id: 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 ---------------------------------------------------------------------------