comp.lang.ada
 help / color / mirror / Atom feed
* Problem with controlled types
@ 1998-12-14  0:00 bourguet
  1998-12-14  0:00 ` Robert A Duff
  1998-12-14  0:00 ` Matthew Heaney
  0 siblings, 2 replies; 6+ messages in thread
From: bourguet @ 1998-12-14  0:00 UTC (permalink / raw)


I've found a CD with Aonix ObjectAda 7.1 Special Edition and tried to
compile a program developped under gnat 3.10. I failed due to the
number of units limitation of the Special Edition :-( but in the
process I found and removed some gnat dependancies. There where place
I had put these dependancies knowingly (like using the os_lib package,
I understand Ada stream better now). But the following one is, IMHO,
the result of bugs in one of the compilers, probably gnat but I prefer
to ask here before report the problem.

with ada.finalization;

package Pkg is

   type A is private;
   --  operations on B

   type B is private;

   function Get_B (I: A) return B;
   -- other operations on B

private

  type A is new Ada.Finalization.Controlled with record
     ...
  end record;

  type B is new Ada.Finalization.Controlled with record
     ...
  end record;

end pkg;

ObjectAda complain that the Get_B function is primitive on two tagged
types, and that is not allowed.

Gnat compile and run correctly (as A'Class contains only A and
B'Class only B, this is not strange).

Now, which one is correct?

-- Jean-Marc

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: Problem with controlled types
  1998-12-14  0:00 Problem with controlled types bourguet
  1998-12-14  0:00 ` Robert A Duff
@ 1998-12-14  0:00 ` Matthew Heaney
  1998-12-14  0:00   ` Tom Moran
  1998-12-14  0:00   ` Tucker Taft
  1 sibling, 2 replies; 6+ messages in thread
From: Matthew Heaney @ 1998-12-14  0:00 UTC (permalink / raw)


bourguet@my-dejanews.com writes:

> with ada.finalization;
> 
> package Pkg is
> 
>    type A is private;
>    --  operations on B
> 
>    type B is private;
> 
>    function Get_B (I: A) return B;
>    -- other operations on B
> 
> private
> 
>   type A is new Ada.Finalization.Controlled with record
>      ...
>   end record;
> 
>   type B is new Ada.Finalization.Controlled with record
>      ...
>   end record;
> 
> end pkg;
> 
> ObjectAda complain that the Get_B function is primitive on two tagged
> types, and that is not allowed.
> 
> Gnat compile and run correctly (as A'Class contains only A and
> B'Class only B, this is not strange).
> 
> Now, which one is correct?

GNAT is correct; ObjectAda is incorrect.

An operation cannot be primitive for more that one type is only true for
(publicly) tagged types.  Since A and B and not publically tagged,
Get_B is a legal operation.





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

* Re: Problem with controlled types
  1998-12-14  0:00 ` Matthew Heaney
@ 1998-12-14  0:00   ` Tom Moran
  1998-12-14  0:00   ` Tucker Taft
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Moran @ 1998-12-14  0:00 UTC (permalink / raw)


>An operation cannot be primitive for more that one type is only true for
>(publicly) tagged types.  Since A and B and not publically tagged,
>Get_B is a legal operation.
  Interesting.  Then 
     procedure P(x: in A; y: in B);
would be legal?  What would it do?




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

* Re: Problem with controlled types
  1998-12-14  0:00 Problem with controlled types bourguet
@ 1998-12-14  0:00 ` Robert A Duff
  1998-12-14  0:00 ` Matthew Heaney
  1 sibling, 0 replies; 6+ messages in thread
From: Robert A Duff @ 1998-12-14  0:00 UTC (permalink / raw)


bourguet@my-dejanews.com writes:

> package Pkg is
> 
>    type A is private;
>    --  operations on B
> 
>    type B is private;
> 
>    function Get_B (I: A) return B;
>    -- other operations on B
> 
> private
> 
>   type A is new Ada.Finalization.Controlled with record
>      ...
>   end record;
> 
>   type B is new Ada.Finalization.Controlled with record
>      ...
>   end record;
> 
> end pkg;
> 
> ObjectAda complain that the Get_B function is primitive on two tagged
> types, and that is not allowed.
> 
> Gnat compile and run correctly (as A'Class contains only A and
> B'Class only B, this is not strange).
> 
> Now, which one is correct?

ObjectAda.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




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

* Re: Problem with controlled types
  1998-12-14  0:00 ` Matthew Heaney
  1998-12-14  0:00   ` Tom Moran
@ 1998-12-14  0:00   ` Tucker Taft
  1998-12-14  0:00     ` Robert I. Eachus
  1 sibling, 1 reply; 6+ messages in thread
From: Tucker Taft @ 1998-12-14  0:00 UTC (permalink / raw)


Matthew Heaney (matthew_heaney@acm.org) wrote:
: bourguet@my-dejanews.com writes:

: > with ada.finalization;
: > 
: > package Pkg is
: > 
: >    type A is private;
: >    --  operations on B
: > 
: >    type B is private;
: > 
: >    function Get_B (I: A) return B;
: >    -- other operations on B
: > 
: > private
: > 
: >   type A is new Ada.Finalization.Controlled with record
: >      ...
: >   end record;
: > 
: >   type B is new Ada.Finalization.Controlled with record
: >      ...
: >   end record;
: > 
: > end pkg;
: > 
: > ObjectAda complain that the Get_B function is primitive on two tagged
: > types, and that is not allowed.
: > 
: > Gnat compile and run correctly (as A'Class contains only A and
: > B'Class only B, this is not strange).
: > 
: > Now, which one is correct?

: GNAT is correct; ObjectAda is incorrect.

: An operation cannot be primitive for more that one type is only true for
: (publicly) tagged types.  Since A and B and not publically tagged,
: Get_B is a legal operation.

Not quite true.  The problem is that *inside* the package private
part and the body, Get_B is primitive on two tagged types,
and that is not legal.  

So ObjectAda wins this round ;-).

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




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

* Re: Problem with controlled types
  1998-12-14  0:00   ` Tucker Taft
@ 1998-12-14  0:00     ` Robert I. Eachus
  0 siblings, 0 replies; 6+ messages in thread
From: Robert I. Eachus @ 1998-12-14  0:00 UTC (permalink / raw)


In article <F3z2s2.6CG.0.-s@inmet.camb.inmet.com> stt@houdini.camb.inmet.com (Tucker Taft) writes:

  > Not quite true.  The problem is that *inside* the package private
  > part and the body, Get_B is primitive on two tagged types,
  > and that is not legal.  

  > So ObjectAda wins this round ;-).

   Interesting.  Try the following example:

generic
  type Out_Type is private;
  type In_Type is new Out_Type;
function Conversion(I: In_Type) return Out_Type;

with Ada.Finalization; with Conversion;
 
package Pkg is
 
   type A is private;

   package Inner is

     type B is private;
     function Convert is new Conversion(A,B);
     -- I'd use Ada.Unchecked_Conversion but that has convention Intrinsic.
   private
     type B is new Ada.Finalization.Controlled with record
        ...
     end record;
   end Inner;

private
 
  type A is new Ada.Finalization.Controlled with record
      ...
  end record;

end Pkg;

   Now according to Tucker, in the private part of Pkg, Convert is a
dispatching operation of A, and in the private part of Inner, it is a
dispatching operation of B.  As written there is no body allowed so
the example is legal.  I could add types C and D and other generic
instantiations to play futher with this.

   I don't think I like either interpretation of 3.9.2(12).
Seriously, 3.9.2(12) says: "A given subprogram shall not be a
dispatching operation of two or more distinct tagged types."  It
doesn't say of two visibly tagged types, so I think my example would
also be illegal.
--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




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

end of thread, other threads:[~1998-12-14  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-14  0:00 Problem with controlled types bourguet
1998-12-14  0:00 ` Robert A Duff
1998-12-14  0:00 ` Matthew Heaney
1998-12-14  0:00   ` Tom Moran
1998-12-14  0:00   ` Tucker Taft
1998-12-14  0:00     ` Robert I. Eachus

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