comp.lang.ada
 help / color / mirror / Atom feed
* Re: polymorphism
@ 1996-11-25  0:00 W. Wesley Groleau (Wes)
  0 siblings, 0 replies; 10+ messages in thread
From: W. Wesley Groleau (Wes) @ 1996-11-25  0:00 UTC (permalink / raw)



:> .... an abstract data type, denoted by the keyword "private" ....

If you must insist on a keyword for an ADT, "abstract" might be better.
But I don't go for that either.  Must we re-define abstract so that it
does not apply to most instances of abstraction?  If "abstract" is
not the opposite of "concrete", then what is the term for something
that is neither?

I consider all of the following "abstract" data types (especially as
compared with "int" and "double"):

type Radians is new Float;

type Payment is
  record
    Gross : some_money_ADT;
    FITW  : some_money_ADT;
    ....

type Months is ( January, February, ....

---------------------------------------------------------------------------
W. Wesley Groleau (Wes)                                Office: 219-429-4923
Hughes Defense Communications (MS 10-40)                 Home: 219-471-7206
Fort Wayne,  IN   46808                  (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------
Object-oriented is a synonym for "great"
My favorite language is xxxx.
My favorite language is great.
Language yyyy is not xxxx.
Therefore, yyyy is not object-oriented.




^ permalink raw reply	[flat|nested] 10+ messages in thread
* Polymorphism
@ 2015-05-06 23:05 slos
  2015-05-07  7:28 ` Polymorphism Simon Wright
  2015-05-07  7:41 ` Polymorphism Dmitry A. Kazakov
  0 siblings, 2 replies; 10+ messages in thread
From: slos @ 2015-05-06 23:05 UTC (permalink / 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

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

end of thread, other threads:[~2015-05-14 21:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-25  0:00 polymorphism W. Wesley Groleau (Wes)
  -- strict thread matches above, loose matches on Subject: below --
2015-05-06 23:05 Polymorphism slos
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

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