From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: Is T an ancestor of T? (was: Re: record extension aggregate for returned type legal?)
Date: Thu, 14 Oct 2004 10:54:00 +0200
Date: 2004-10-14T10:54:00+02:00 [thread overview]
Message-ID: <1406724.hY6njLzCIG@linux1.krischik.com> (raw)
In-Reply-To: ckjlhm$2hh$1@a1-hrz.uni-duisburg.de
Georg Bauhaus wrote:
> Martin Krischik <krischik@users.sourceforge.net> wrote:
> : Georg Bauhaus wrote:
> :
> :> LRM 4.3.2, quoted in one compiler's error message, says,
> :>
> :> 4. The expected type for an extension_aggregate shall be a single
> :> nonlimited type that is a record extension. If the ancestor_part
> :> is an expression, it is expected to be of any nonlimited tagged
> :> type.
> :>
> :> Do I understand this phrase? The expected type in the return expression
> :> for "function make return T" is the specific tagged type T.
> :> In "return (n => 0)", there is no extension aggregate.
> :> In "return (T with n => 0)", there is an extension aggregate,
> :> the ancestor part being T.
> :
> : But T in your example is a root class and therefore has no ancestor.
>
> T seems to have an ancestor, by the following statement form LRM
> 3.4.1(10): "A specific type T2 is defined to be a descendant of a type T1
> if T2 is the same as T1, or if T2 is derived (directly or indirectly) from
> T1."
Wow. Would not have thought that.
> So T can be T's ancestor (that's different from what I was used to
> in the real world ;-).
Well thinking about it: It's probably needed for dispatching calls.
> 'class as return type of constructor functions creates a number of
> not-so-nice conversion necessities that I'd like to avoid.
I thought as an example. Not to actually use this constructor pattern.
> All issues are easily avoided using the constructor child package
> pattern.
If it suits your problem best.
> Now is GNAT right,
> accepting return (T with n => 0), and
> accepting return (n => 0)
> or is ObjectAda right,
> rejecting return (T with n => 0), but
> accepting return (n => 0)
> where T is the expected tagged return type (not classwide)?
I thing Object Ada is right. The aggregate allows you to move up the the
tree. i.E.
type R is tagged private;
type P is new R with private;
type C is new P with private;
X : C := (R with P_Attribute => ..., C_Attribute => ...)
R is default initialised. P and C are specified. Now, if you move that line
of thought into the other direction you have just defined n twice. Look:
return (T with n => 0)
T is allready default initialised - and then you specify n again.
With Regards
Martin
--
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com
next prev parent reply other threads:[~2004-10-14 8:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-12 1:31 record extension aggregate for returned type legal? Georg Bauhaus
2004-10-12 8:04 ` Martin Krischik
2004-10-12 14:36 ` Georg Bauhaus
[not found] ` <1940150.rU8f1KaX3L@linux1.krischik.com>
2004-10-12 20:24 ` Georg Bauhaus
2004-10-13 7:52 ` Martin Krischik
[not found] ` <ckjlhm$2hh$1@a1-hrz.uni-duisburg.de>
[not found] ` <ukhbd.106086$dP1.396181@newsc.telia.net>
2004-10-14 0:29 ` Is T an ancestor of T? Georg Bauhaus
2004-10-14 8:54 ` Martin Krischik [this message]
[not found] ` <ckot3m$hek$1@a1-hrz.uni-duisburg.de>
2004-10-15 16:55 ` Martin Krischik
2004-10-15 17:19 ` Georg Bauhaus
2004-10-16 14:37 ` Martin Krischik
2004-10-13 16:18 ` record extension aggregate for returned type legal? Jean-Pierre Rosen
[not found] ` <87ekk0hvfq.fsf@beeblebrox.rfc1149.net>
2004-10-15 16:51 ` Martin Krischik
[not found] ` <t7tokc.2he.ln@skymaster>
2004-10-15 17:22 ` Georg Bauhaus
2004-10-14 20:04 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox