comp.lang.ada
 help / color / mirror / Atom feed
From: dhunter@interserf.net (David Hunter)
Subject: Re: Question about tagged types and functions
Date: 1996/05/22
Date: 1996-05-22T00:00:00+00:00	[thread overview]
Message-ID: <4nvhdo$ri7@ns.interserf.net> (raw)
In-Reply-To: 4xpw7xpoc6.fsf@leibniz.enst-bretagne.fr


In article <4xpw7xpoc6.fsf@leibniz.enst-bretagne.fr>, 
Laurent.Guerby@enst-bretagne.fr says...
>
>David> Why does Ada-95 (GNAT 3.01a) tell me that I also *must* have:
>
>David>     function Create return DerivedType;
>
>David> There is something going on with tagged types and functions
>David> that I don't understand because if I use
>
>David>     procedure Create(a : out BaseType);
>
>David> it (Ada-95) does not object.
>
>   The status of functions (primitives) that dispatch on result is
>special in Ada 95. See RM95-3.9.3(4-6). Or better, read the paper "Ada
>9X Tagged Types and their Implementation in GNAT" by Cyrille Comar and
>Brett Porter

Thank you for your timely response.

I read this paper and there is indeed a paragraph that explictly
addresses my question.  They explain that the overloading of Create is
necessary because: "otherwise the inherited function would return
an object of the parent type, that is to say an incomplete
object."  Obviously I can see that you want to avoid any
situation in which you end up with "derived_object := parent_object"
but doesn't Ada-95 forbid that anyway?  I mean, you couldn't do

	d : DerivedType;
	b : BaseType;
	d := b;

so the error "d := Create;" would be caught by the type
rules anyway, right?  I guess I'm back to my original
question.  Maybe it would help if someone could provide
an example in which the problem described by the
paper occurs (one that would not be otherwise detected).

==============================
David Hunter (hunter@mwc.edu)
CPSC Dept.
Mary Washington College
Fredericksburg, VA 22401






  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 [this message]
1996-05-22  0:00 ` Jon S Anthony
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