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.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Received: by 10.36.10.20 with SMTP id 20mr168214itw.30.1518477176222; Mon, 12 Feb 2018 15:12:56 -0800 (PST) X-Received: by 10.157.113.143 with SMTP id o15mr495802otj.6.1518477175978; Mon, 12 Feb 2018 15:12:55 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!w142no1148771ita.0!news-out.google.com!s63ni2740itb.0!nntp.google.com!w142no1148770ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 Feb 2018 15:12:55 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.154.189.221; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 82.154.189.221 References: <634e9064-33f8-42c0-9032-e630f98c89d4@googlegroups.com> <982639bc-8e7e-4c43-a1ff-cf9fa7c0d0ed@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: Mehdi Saada <00120260a@gmail.com> Injection-Date: Mon, 12 Feb 2018 23:12:56 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:50404 Date: 2018-02-12T15:12:55-08:00 List-Id: Ah !! Thanks, you made remember I could do, which works: case GET_ELEM (T_Token_Operateur(I.all)) is I used to think that conversion from a class-wide type to a child type need not 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 => ';'); I could do the same with '+' | '-' | '*' | '/', but it would suck. I so want something like when '+' | '-' | '*' | '/' => V_LOCAL (I) := new T_Token_Operateur'(L_Operateur => T_Operateur(ELEMENT)); But the conversion isn't valid, as I said. This is my last error, said the compiler. Thanks to you !