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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,814577151c84863d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-17 10:55:19 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!63.218.45.10.MISMATCH!nx01.iad01.newshosting.com!nx02.iad01.newshosting.com!newshosting.com!border1.nntp.ash.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!mephistopheles.news.clara.net!news.clara.net!wagner.news.clara.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Lionel.DRAGHI@fr.thalesgroup.com Newsgroups: comp.lang.ada Subject: RE: which compiler is right? Date: Wed, 17 Mar 2004 19:53:12 +0100 Organization: Cuivre, Argent, Or Message-ID: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: melchior.cuivre.fr.eu.org 1079549637 84730 212.85.156.195 (17 Mar 2004 18:53:57 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Wed, 17 Mar 2004 18:53:57 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: X-Mailer: Internet Mail Service (5.5.2653.19) X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:6384 Date: 2004-03-17T19:53:12+01:00 | -----Message d'origine----- | De: adam@irvine.com [mailto:adam@irvine.com] ... | > -- --------------------------------------------------------------- | > package Pkg1 is | > | > type T_Event is abstract tagged null record; | > | > function Priority (Event : T_Event) return Natural is abstract; | > | > end Pkg1; | > | > -- --------------------------------------------------------------- | > with Pkg1; | > | > generic | > type T_Event (<>) is new Pkg1.T_Event with private; | > | > package Pkg2 is | > function Priority (Event : in T_Event) return Natural; | > | > -- OK for GNAT 3.16a (20030120) | > -- KO for ObjectAda (tm) Version 7.2.1 : ... | > | > end Pkg2; | | Since the score is currently 2-0 that the code should be illegal, | maybe I should point out that not everyone agrees with this analysis, | before you decide it's necessary to fix your code. My belief is that | since the Priority routine declared in Pkg2 is declared in a different | scope than whatever type will be used to instantiate Pkg2, Priority is | neither a primitive subprogram nor is overriding. I think GNAT is | correct to accept the code. | Thank you Adam. I was feeling it this way. I was not considering the formal parameter like a real class, or like a place older where the root abstract Priority should be visible. So there was no late overriding at this stage for me. And at instanciation time, the created Priority operation is in the instanciated package scope, so there should be no problem. But this is a user's view, not a layer's view. For the record, here is how I use those packages: I provide the concrete realization of Priority by renaming the one in the generic instantiation. with Pkg1; package Pkg3 is type T_Event is new Pkg1.T_Event with null record; function Priority (Event : in T_Event) return Natural; end Pkg3; with Pkg2; package body Pkg3 is package Pkg2_Instanciation is new Pkg2 (T_Event); function Priority (Event : in T_Event) return Natural renames Pkg2_Instanciation.Priority; end Pkg3; GNAT is behaving exactly like expected (by me, at least :-). -- Lionel Draghi