comp.lang.ada
 help / color / mirror / Atom feed
From: Bojan Bozovic <bozovic.bojan@gmail.com>
Subject: Re: troubles learning OOP: expected type "Parent.Some_Child", found type Parent'Class
Date: Mon, 12 Feb 2018 20:16:27 -0800 (PST)
Date: 2018-02-12T20:16:27-08:00	[thread overview]
Message-ID: <ba3241d9-97f6-4c02-be61-ff22a0fd1af4@googlegroups.com> (raw)
In-Reply-To: <58302fb3-4b2d-4651-82ca-1efa0b2de8f3@googlegroups.com>

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.

  reply	other threads:[~2018-02-13  4:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 16:29 troubles learning OOP: expected type "Parent.Some_Child", found type Parent'Class Mehdi Saada
2018-02-12 17:44 ` Jeffrey R. Carter
2018-02-12 18:17   ` Mehdi Saada
2018-02-12 18:24     ` Dmitry A. Kazakov
2018-02-12 18:42       ` Simon Wright
2018-02-12 20:25     ` Jeffrey R. Carter
2018-02-12 21:18       ` Mehdi Saada
2018-02-12 22:40         ` Simon Wright
2018-02-12 23:12           ` Mehdi Saada
2018-02-13  8:00         ` Stephen Leake
2018-02-13 17:42         ` Jeffrey R. Carter
2018-02-13 17:56           ` Dmitry A. Kazakov
2018-02-12 21:19       ` Mehdi Saada
2018-02-12 18:40   ` Simon Wright
2018-02-12 21:39 ` Mehdi Saada
2018-02-12 21:43 ` Mehdi Saada
2018-02-12 22:22   ` Mehdi Saada
2018-02-13 17:46     ` Jeffrey R. Carter
2018-02-13 20:19       ` Mehdi Saada
2018-02-13 21:24         ` Bojan Bozovic
2018-02-13 23:03           ` Mehdi Saada
2018-02-13 23:03             ` Mehdi Saada
2018-02-14  7:00               ` Bojan Bozovic
2018-02-14 12:04                 ` Mehdi Saada
2018-02-16 23:40                   ` Mehdi Saada
2018-02-17  1:13                     ` Mehdi Saada
2018-02-13  0:01 ` Mehdi Saada
2018-02-13  0:42   ` Mehdi Saada
2018-02-13  1:32     ` Mehdi Saada
2018-02-13  4:16       ` Bojan Bozovic [this message]
2018-02-13 11:28       ` Simon Wright
2018-02-13 12:03         ` Mehdi Saada
2018-02-13 13:25         ` Dmitry A. Kazakov
2018-02-19 18:10 ` Mehdi Saada
2018-02-19 18:16   ` Simon Clubley
replies disabled

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