comp.lang.ada
 help / color / mirror / Atom feed
From: Lionel.DRAGHI@fr.thalesgroup.com
To: comp.lang.ada@ada-france.org
Subject: RE: which compiler is right?
Date: Wed, 17 Mar 2004 19:53:12 +0100
Date: 2004-03-17T19:53:12+01:00	[thread overview]
Message-ID: <mailman.104.1079549636.327.comp.lang.ada@ada-france.org> (raw)



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




             reply	other threads:[~2004-03-17 18:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-17 18:53 Lionel.DRAGHI [this message]
2004-03-18  4:57 ` which compiler is right? Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2004-03-17 18:56 Lionel.DRAGHI
2004-03-17 10:16 Lionel.DRAGHI
2004-03-17 17:48 ` Randy Brukardt
2004-03-16 15:35 Lionel.DRAGHI
2004-03-16 13:44 Lionel.DRAGHI
2004-03-16 14:56 ` Dmitry A. Kazakov
2004-03-16 23:43 ` Randy Brukardt
2004-03-17 17:27 ` Adam Beneschan
2004-03-18  5:07   ` Randy Brukardt
2004-03-18 20:33     ` Adam Beneschan
2004-03-19 19:48       ` Randy Brukardt
1997-07-24  0:00 Which compiler is right ? Strategies
1997-07-25  0:00 ` Albert K. Lee
1997-07-25  0:00 ` Tucker Taft
replies disabled

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