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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.47.102 with SMTP id j99mr11133064ioo.51.1518495388190; Mon, 12 Feb 2018 20:16:28 -0800 (PST) X-Received: by 10.157.32.3 with SMTP id n3mr512748ota.12.1518495388032; Mon, 12 Feb 2018 20:16:28 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!feed.usenet.farm!feeder4.usenet.farm!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!o66no1211819ita.0!news-out.google.com!m16ni2863itm.0!nntp.google.com!o66no1211813ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 Feb 2018 20:16:27 -0800 (PST) In-Reply-To: <58302fb3-4b2d-4651-82ca-1efa0b2de8f3@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=87.116.179.50; posting-account=z-xFXQkAAABpEOAnT3LViyFXc8dmoW_p NNTP-Posting-Host: 87.116.179.50 References: <634e9064-33f8-42c0-9032-e630f98c89d4@googlegroups.com> <5f36f0ae-87ed-4482-9766-561b63b1d343@googlegroups.com> <58302fb3-4b2d-4651-82ca-1efa0b2de8f3@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: troubles learning OOP: expected type "Parent.Some_Child", found type Parent'Class From: Bojan Bozovic Injection-Date: Tue, 13 Feb 2018 04:16:28 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:50408 Date: 2018-02-12T20:16:27-08:00 List-Id: On Tuesday, February 13, 2018 at 2:32:42 AM UTC+1, Mehdi Saada wrote: > I used to think that conversion from a class-wide type to a child type need t ever be explicit, I was wrong, and it's safer that way of course. > It's better to use as little redispatching or dynamic whatever as possible. I did: > > ELEMENT : Character renames STRING_VECTOR(Current_Index); > case ELEMENT is > when '(' => V_LOCAL (I) := new T_TOKEN_PARENTHESE'(La_Parenthese => '('); > when ')' => V_LOCAL (I) := new T_TOKEN_PARENTHESE'(La_Parenthese => ')'); > when ';' => V_LOCAL (I) := new T_TOKEN_TERMINATEUR'(Le_Terminateur => ';'); > when '+' | '-' | '*' | '/' => > V_LOCAL (I) := new T_Token_Operateur'(L_Operateur => T_Operateur'Value (STRING'(1 => ELEMENT))); > > The last error (hope none more will pop up !) is > PUSH (PILE, To_Token(TEMP_PRIORITE.L_Operateur)'Access); > > considered that > type PTR_TOKEN_CLASS is access constant T_Token'Class; > package P_PILE_1 is new P_Pile_4 (T_Elem => PTR_TOKEN_CLASS, Max_Pile => V_ENTREE'Length); > use P_PILE_1, P_Pile_2; > PILE : P_PILE_1.T_Pile(50); > > I got "prefix of "Access" attribute must be aliased", which is logical, but how do I aliase the result of a conversion ? You alias the function or procedure, for result to be a pointer, you can't return pointer directly. I don't see all your code but I can provide link https://en.wikibooks.org/wiki/Ada_Programming/Types/access#Access_to_Subprogram At least that seems to be a problem. Forgive me if I'm wrong.