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,fc203759328316c2 X-Google-Attributes: gid103376,public From: jsa@organon.com (Jon S Anthony) Subject: Re: Question about tagged types and functions Date: 1996/05/22 Message-ID: #1/1 X-Deja-AN: 156184240 sender: news@organon.com (news) references: <4ntg05$qgc@ns.interserf.net> organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-05-22T00:00:00+00:00 List-Id: In article <4ntg05$qgc@ns.interserf.net> dhunter@interserf.net (David Hunter) writes: > package Test is > > type BaseType is tagged record > null; > end BaseType; > > function Create return BaseType; > > type DerivedType is new BaseType with record > null; > end DerivedType; > > end Test; > > Why does Ada-95 (GNAT 3.01a) tell me that I also > *must* have: > > function Create return DerivedType; > > There is something going on with tagged types > and functions that I don't understand because > if I use > > procedure Create(a : out BaseType); > > it (Ada-95) does not object. The short answer is that the would be non-overridden inherited Create would not provide values for any extension components in the derived type and so the value it would return would be ill defined. Now, in your case, there are no extension components, but special casing for this situation is not a particularly good idea for several reasons. Admittedly, this is virtually impossible to find in the ARM95 if you go looking for it. Why? Because it is stuck away in 3.9.3, the major topic of which is _abstract_ types and subprograms. In particular, see paragraphs (4-6). This really should have been mentioned (perhaps in addition to the 3.9.3 comments) in 3.4. Say between (22) and (23). /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com