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,da9f9995bafb51df X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.202.37 with SMTP id kf5mr474052pbc.7.1333782383058; Sat, 07 Apr 2012 00:06:23 -0700 (PDT) Path: r9ni28085pbh.0!nntp.google.com!news2.google.com!goblin1!goblin2!goblin.stu.neva.ru!feeder.erje.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Assigning a "subclass" instance to a "superclass" variable Date: Sat, 7 Apr 2012 09:06:14 +0200 Organization: cbb software GmbH Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: Gbl624r6iuNIccy3ASy5ag.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-04-07T09:06:14+02:00 List-Id: On Fri, 6 Apr 2012 23:13:40 +0000 (UTC), deuteros wrote: > I want something like a constructor in my child classes: > > function Create_Expression (tokens, executedtokens : Vector) return Expression is > E : Expression > begin > E.tokens := tokens; > E.executedtokens := executedtokens; > return E; > end Create_Expression; > > Now if the Expression package must have its own tokens and executedtokens > I assume this would be the way to do it but if not then how would this > work? Then the parent type (Statement) should not have them in its implementation. If children have token types of their own (a parallel types hierarchy), you should provide an abstract interface to access child-specific tokens. E.g. function Get_Token (S : Statement; Index : Token_Index_Type) return Token_Type'Class is abstract; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de