comp.lang.ada
 help / color / mirror / Atom feed
From: firth@sei.cmu.edu (Robert Firth)
Subject: Re: Initialization
Date: 14 Jun 90 17:38:46 GMT	[thread overview]
Message-ID: <7540@fy.sei.cmu.edu> (raw)
In-Reply-To: 1957@sparko.gwu.edu

In article <1957@sparko.gwu.edu> mfeldman@seas.gwu.edu (Michael Feldman) writes:
>I have a rationale-type questions regarding an apparent irregularity
>in Ada, namely in the area of default initializations.

There is no good reason for the irregularity.  Since a record
component can be of any type, the implementation of

	record
	  Component : Thing := Initial_Value;
	end record;

is no more and no less difficult than the implementation of

	type Thing is Type_Definition := Initial_Value;

would be.  There are no serious parsing difficulties with the
above syntax, and no additional semantic issues.

The reason for the irregularity is historical.  In the original
Green language, the syntax of a record type definition read

	record_type_definition ::= RECORD component_list END RECORD

	component_list ::= {object_declaration} [variant_part] | NULL ;

Because the syntax of object_definition was reused, the ability to
initialise the component got carried over automatically.  When this
was noticed, it was decided that this was a useful thing to have.

I recall asking Jean why he didn't make the type model more regular
by allowing all types to have initialisation expressions, and his
reply was that you could always achieve this effect by nesting the
type you wanted in a record, and he didn't want to add extra syntax.
Please do not ask me to defend this position.

  reply	other threads:[~1990-06-14 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-06-14 16:37 Initialization Michael Feldman
1990-06-14 17:38 ` Robert Firth [this message]
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