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/23
Date: 1996-05-23T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96May22214653@organon.com> (raw)
In-Reply-To: 4ntg05$qgc@ns.interserf.net


In article <4nvhdo$ri7@ns.interserf.net> dhunter@interserf.net (David Hunter) writes:

> 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?

This is pretty much why the error is being flagged the way it is.  If
you assume that the current rule was not there and you did not have to
override, then a new Create with result type DerivedType is implicitly
declared _immediately_ after the declaration of DerivedType.  So, the
case you site:

    d := Create;

would not have any type error at all.  But, the actual Create bound
here would be the Create with result type BaseType with an implicit
conversion on the resulting object _away_ from the root of BaseType
to DerivedType.  Ba-Boom!  See 3.4(17-23, 27) and 3.9.2(20).

/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-23  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 ` Jon S Anthony
1996-05-22  0:00 ` Laurent Guerby
1996-05-22  0:00   ` David Hunter
1996-05-23  0:00 ` Jon S Anthony [this message]
replies disabled

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