comp.lang.ada
 help / color / mirror / Atom feed
From: slos <new.stephane.los@gmail.com>
Subject: Polymorphism
Date: Wed, 6 May 2015 16:05:28 -0700 (PDT)
Date: 2015-05-06T16:05:28-07:00	[thread overview]
Message-ID: <da4139a7-d66a-4153-a68f-7eca4c8982b0@googlegroups.com> (raw)

Hello,

Please consider the following simple case :

package Object is
   
   type Instance is abstract tagged private;
   
   function Distance (O : Instance'Class) return Float;
   
   function Weight (O : Instance'Class; Coef : Float) return Float;
   --  returns Area * Coef
   
   function Area (O : Instance) return Float is abstract;
   
private
   
   type Instance is abstract tagged
      record
         X_Coord : Float;
         Y_Coord : Float;
      end record;
   
end Object;

with Object; use Object;

package Circle is

   type Instance is new Object.Instance with private;

private

   type Instance is new Object.Instance with
      record
         Radius : Float;
      end record;

   overriding
   function Area (C : Instance) return Float;

end Circle;

I'd like function Object.Area to stay private but the compiler doesn't see it like that and complains if I try to move it in the private part.

In other words, I'd like to not expose internals to clients of the package.

Any hint to achieve that ?

Thanks in advance.

BR,
Stéphane

             reply	other threads:[~2015-05-06 23:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 23:05 slos [this message]
2015-05-07  7:28 ` Polymorphism Simon Wright
2015-05-07  8:32   ` Polymorphism slos
2015-05-07  7:41 ` Polymorphism Dmitry A. Kazakov
2015-05-07  8:34   ` Polymorphism slos
2015-05-07 19:09   ` Polymorphism Randy Brukardt
2015-05-11 22:05     ` Polymorphism slos
2015-05-12  1:29       ` Polymorphism Randy Brukardt
2015-05-14 21:34         ` Polymorphism slos
  -- strict thread matches above, loose matches on Subject: below --
1996-11-25  0:00 polymorphism W. Wesley Groleau (Wes)
replies disabled

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