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,3e9f0e99a5a40441 X-Google-Attributes: gid103376,public From: stt@spock.camb.inmet.com (Tucker Taft) Subject: Re: Deriving from non-null abstract type Date: 1995/03/29 Message-ID: #1/1 X-Deja-AN: 100540692 sender: news@inmet.camb.inmet.com references: <3lbh2q$8ov@israel-info.datasrv.co.il> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1995-03-29T00:00:00+00:00 List-Id: Moti Ben-Ari (benari@zeus.datasrv.co.il) wrote: : I would like to derive from a _non-null_ abstract tagged type: : type Abstract_Type is abstract tagged : record : General_Info: Some_Type; : end record; : type Derived_Type is new Abstract_Type with : record : Special_Info: Some_Other_Type; : end record; : Of course, you can't create a value of the abstract type, : but it turns out that it is impossible to create a value : of the derived type: : D: Derived_Type := (G with S); : because G would have to be an aggregate of an abstract type : which is illegal. There is no need to use an extension aggregate at all. You can use "regular" record aggregates if you are giving all of the components of a record extension, including those inherited from the parent type. Hence, the following is the appropriate way to initialize all of the components of a record extension: D : Derived_Type := (General_Info => General_Value, Special_Info => S); or positionally: D : Derived_Type (General_Value, S); : ... The only thing you can do is: : D: Derived_Type := (Abstract_Type with S); : which means that the component General_Info has to : be initialized in a separate statement. This kind of aggregate is to be used when you want to default-initialize the inherited components. If you want to initialize them, then as indicated above, just use a regular record aggregate. : This seems to be against the philosophy of Ada which : provides aggregates so that you won't forget to initialize : a component. : Is there some way of creating a value that I don't see? Yes -- use a regular record aggregate. : If not, why aren't abstract types restricted to null records? See above. : Moti : Moti Ben-Ari : benari@datasrv.co.il -Tucker Taft stt@inmet.com Intermetrics, Inc.