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: Simon Wright Newsgroups: comp.lang.ada Subject: Re: troubles learning POO: expected type "Parent.Some_Child", found type Parent'Class Date: Mon, 12 Feb 2018 16:35:28 +0000 Organization: A noiseless patient Spider Message-ID: References: <595e044c-e71b-401e-902b-ab70d2730ee1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="b6495a8dbc2779c7727059ea44b5e007"; logging-data="18006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/mAyrRqYn7j1VU34rFUXLykiBmfXO84s=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:SdJoFNzUfabu+ZZQIzuj1ecAqr0= sha1:udl/po4RFzJlXK661YcDLaXg6Rg= Xref: reader02.eternal-september.org comp.lang.ada:50388 Date: 2018-02-12T16:35:28+00:00 List-Id: Mehdi Saada <00120260a@gmail.com> writes: > 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 This is because you've declared > function Get_Elem (Token : in T_Token_Operateur) return T_Operateur > is (Token.L_Operateur); You don't say what T_Operateur is, though it appears to be a Character. If you declare > type T_TOKEN is abstract null record ; function Get_Elem (Token : in T_Token) return String is abstract; then Get_Elem is primitive, and you could declare function Get_Elem (Token : in T_Token_Operateur) return String; and you'd get dispatching on the Token parameter when you supply a T_Token'Class. But that that requires that the Token parameter is in T_Token'Class and that the other parameters, if any, and the return type match exactly. Which gives you a problem since you've stored L_Operateur as a T_Operateur. You could return (String'(1 => Token.L_Operateur)). (I'm assuming that other kinds of token could be longer than 1 character).