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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,73057f1a3ca11607 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada 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 Organization: AdaCL Message-ID: <1406724.hY6njLzCIG@linux1.krischik.com> References: <1738418.atIT6LYH9Z@linux1.krischik.com> <1940150.rU8f1KaX3L@linux1.krischik.com> <6577257.BAFHMKqgPc@linux1.krischik.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1097744195 01 2844 yllRX-pOFjxkBlF 041014 08:56:35 X-Complaints-To: usenet-abuse@t-online.de X-ID: V93lF4ZUQeQXDMFFo1InQIYgcJEI6LKgQ8wpG88IFTimrQGbzJ1WEm User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:5189 Date: 2004-10-14T10:54:00+02:00 List-Id: Georg Bauhaus wrote: > Martin Krischik 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