comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: troubles learning POO: expected type "Parent.Some_Child", found type Parent'Class
Date: Mon, 12 Feb 2018 16:35:28 +0000
Date: 2018-02-12T16:35:28+00:00	[thread overview]
Message-ID: <lyzi4ekvxr.fsf@pushface.org> (raw)
In-Reply-To: 595e044c-e71b-401e-902b-ab70d2730ee1@googlegroups.com

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).


      reply	other threads:[~2018-02-12 16:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 15:33 troubles learning POO: expected type "Parent.Some_Child", found type Parent'Class Mehdi Saada
2018-02-12 16:35 ` Simon Wright [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox