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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: troubles learning OOP: expected type "Parent.Some_Child", found type Parent'Class Date: Mon, 12 Feb 2018 18:44:59 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <634e9064-33f8-42c0-9032-e630f98c89d4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 12 Feb 2018 17:45:00 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="dc3bc383579800cb7f30ff6e7b14cb6f"; logging-data="17380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18daflY9TyO/TIRpC8PAYaX15ukcZGQFqY=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-Reply-To: <634e9064-33f8-42c0-9032-e630f98c89d4@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:heE4RMwSnFv59PFsPAQVuXVbuVc= Xref: reader02.eternal-september.org comp.lang.ada:50389 Date: 2018-02-12T18:44:59+01:00 List-Id: On 02/12/2018 05:29 PM, Mehdi Saada wrote: > I'm learning POO. What you're learning is type extension. By far most of the questions on here where the language doesn't do what is expected deal with anonymous access types and type extension. That's because they're parts of the language that are counter-intuitive and confusing. You're doing both. Don't do that, and things will be much easier. But if you're taking a course and have to mess with type extension, at least you should avoid the access types. > I have trouble, indeed. Please look at this: > > if GET_ELEM (TOKEN_COURANT) = '(' then VALIDE; > --> > expected type "T_Token_Operateur" defined > Found type T_TOKEN'Class > > function Get_Elem (Token : in T_Token_Operateur) return T_Operateur is (Token.L_Operateur); That clearly takes a T_Token_Operateur. > function TOKEN_COURANT return T_TOKEN'Class is and that clearly return T_Token'Class, just as the error msg said. It seems you have 3 choices: Make Get_Elem take T_Token'Class, make Token_Courant return T_Token_Operateur, or convert the result of Token_Courant to T_Token_Operateur. -- Jeff Carter "You a big nose have it." Never Give a Sucker an Even Break 107