comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@organon.com (Jon S Anthony)
Subject: Re: Question about tagged types and functions
Date: 1996/05/22
Date: 1996-05-22T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96May22153038@organon.com> (raw)
In-Reply-To: 4ntg05$qgc@ns.interserf.net


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





  parent reply	other threads:[~1996-05-22  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-21  0:00 Question about tagged types and functions David Hunter
1996-05-22  0:00 ` Laurent Guerby
1996-05-22  0:00   ` David Hunter
1996-05-22  0:00 ` Jon S Anthony [this message]
1996-05-23  0:00 ` Jon S Anthony
replies disabled

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