comp.lang.ada
 help / color / mirror / Atom feed
* which compiler is right?
@ 2004-03-16 13:44 Lionel.DRAGHI
  2004-03-16 14:56 ` Dmitry A. Kazakov
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Lionel.DRAGHI @ 2004-03-16 13:44 UTC (permalink / raw)
  To: comp.lang.ada

Could someone, please, tell me if this code compile with other compilers
than GNAT and ObjectAda?
Or even better, is ObjectAda right in rejecting it?

Thanks in advance

-- 
Lionel Draghi


-- ---------------------------------------------------------------
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 :
   --
   --      7    function Priority (Event : in T_Event) return Natural;
   --                    *
   --  *****Error: LRM:3.9.2(13) a primitive subprogram of a tagged type may
not be
   --  *****        declared after the type is frozen

end Pkg2;




^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: which compiler is right?
@ 2004-03-17 18:56 Lionel.DRAGHI
  0 siblings, 0 replies; 16+ messages in thread
From: Lionel.DRAGHI @ 2004-03-17 18:56 UTC (permalink / raw)
  To: comp.lang.ada



| -----Message d'origine-----
| De: Randy Brukardt [mailto:randy@rrsoftware.com]
...
| 
| I did post this on Ada-Comment. And I got three different 
| answers. About all
| that is agreed upon is that there is a hole in the language. 
| But whether it
| ought to be illegal or not is open to question. I presume 
| that an AI will be
| opened.
| 
Thank you.

| So I'd strongly recommend avoiding this construct completely, 
| because there
| is no agreement on what the language ought to say or 
| compilers ought to
| do -- and it may take years to sort it out. (And we may 
| ultimately decide
| that it is illegal.)
| 
That make sense, but  I will wait for both support answer before deciding to
change the code. 
In the mean time, I will explain on cla the context, just to be sure that
there is no simple solution to my problem.

-- 
Lionel Draghi



^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: which compiler is right?
@ 2004-03-17 18:53 Lionel.DRAGHI
  2004-03-18  4:57 ` Randy Brukardt
  0 siblings, 1 reply; 16+ messages in thread
From: Lionel.DRAGHI @ 2004-03-17 18:53 UTC (permalink / raw)
  To: comp.lang.ada



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




^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: which compiler is right?
@ 2004-03-17 10:16 Lionel.DRAGHI
  2004-03-17 17:48 ` Randy Brukardt
  0 siblings, 1 reply; 16+ messages in thread
From: Lionel.DRAGHI @ 2004-03-17 10:16 UTC (permalink / raw)
  To: comp.lang.ada



| -----Message d'origine-----
| De: Randy Brukardt [mailto:randy@rrsoftware.com]
...
| 
| "Which compiler is right?"
| 
| Typically, that's irrelevant. You have to avoid any construct 
| that doesn't
| work with any of the compilers, because the turn-around time 
| for a fix is
| too long to wait for. (That's especially true for something 
| like Claw.)
| Anyway...
Typically, yes, but not in my case.
Because of projects roadmap, I have the possibility to wait for ObjectAda
fixes.  
But if GNAT is wrong accepting this code, then I must change it now.

And also (like for the other anectotical example I posted yesterday), even
if it's easy to avoid, I don't want the Ada compilers I am using disagreeing
on Ada semantics.


...
| I think the program is illegal, but certainly not for the reasons that
| ObjectAda is reporting. But perhaps this is one of the cases 
| where something
| completely unrelated is fixing a bug elsewhere in the 
| language (because I
| cannot figure out a reason for it to be illegal other than 
| freezing - which
| has nothing to do with this).
| 
| The inherited Priority routine is primitive by 3.2.3. 8.3 
| then says that the
| new declaration overrides it. Of course, this is bogus, 
| because the type is
| not even declared in this scope, so any such overriding has 
| to be illegal.
| But I can't find any reason for that. OA says that the type 
| is frozen, but
| there really isn't any reason to assume that (and that may 
| not be true in
| Ada 2005 anyway). Even if the type was not frozen, we'd still 
| want this to
| be illegal.
| 
Thank you Randy for your analysis. 

| Looks like Ada-Comment material to me.
Should I just send an informal mail, like the one I posted on cla?
Maybe with the underlying problem that lead to this code?

-- 
Lionel Draghi



^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: which compiler is right?
@ 2004-03-16 15:35 Lionel.DRAGHI
  0 siblings, 0 replies; 16+ messages in thread
From: Lionel.DRAGHI @ 2004-03-16 15:35 UTC (permalink / raw)
  To: comp.lang.ada



| -----Message d'origine-----
| De: Dmitry A.Kazakov [mailto:mailbox@dmitry-kazakov.de]
...
| with Pkg1;
| generic
|    type T_Event (<>) is new Pkg1.T_Event with private;
| package Pkg2 is
|    function Priority (Event : in T_Event) return Natural;
| 
| Looks much like GNAT error. In any case the above makes little sense.
| If you want to override Priority you should declare a new type in
| Pkg2:
...
It's not what I want to do.
Don't expect to get some sound design from this code, it's just the smallest
subset I could get causing the compilation difference.

-- 
Lionel Draghi



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Which compiler is right ?
@ 1997-07-24  0:00 Strategies
  1997-07-25  0:00 ` Tucker Taft
  1997-07-25  0:00 ` Albert K. Lee
  0 siblings, 2 replies; 16+ messages in thread
From: Strategies @ 1997-07-24  0:00 UTC (permalink / raw)



Hello
Is the following code legal ?
I have two compilers with two different answers

generic
   type Element_Type is limited private;
   type Index_Type is (<>);
   type Element_Array is array (Index_Type range <>) of Element_Type;
   with function Equal (Left, Right : Element_Type) 
	return Boolean is "=";   
function Generic_Indice (Left  :
Element_Type;                          			 Right : Element_Array) return
Index_Type;
-- 
------------------------------------------------------------------------
-- Jerome HAGUET, Strategies, Rungis, France 			      --
-- Tel : (33 1 | 01) 41 73 04 80  ;   Fax : (33 1 | 01) 41 73 04 99   --
-- Internet : strategies@magic.fr ;   Compuserve : 100747,2001        --
------------------------------------------------------------------------





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-03-19 19:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-16 13:44 which compiler is right? 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
  -- strict thread matches above, loose matches on Subject: below --
2004-03-17 18:56 Lionel.DRAGHI
2004-03-17 18:53 Lionel.DRAGHI
2004-03-18  4:57 ` Randy Brukardt
2004-03-17 10:16 Lionel.DRAGHI
2004-03-17 17:48 ` Randy Brukardt
2004-03-16 15:35 Lionel.DRAGHI
1997-07-24  0:00 Which compiler is right ? Strategies
1997-07-25  0:00 ` Tucker Taft
1997-07-25  0:00 ` Albert K. Lee

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