comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Polymorphism
Date: Thu, 7 May 2015 09:41:58 +0200
Date: 2015-05-07T09:41:58+02:00	[thread overview]
Message-ID: <5hbl45anxasb.1jn73i00zgy2i.dlg@40tude.net> (raw)
In-Reply-To: da4139a7-d66a-4153-a68f-7eca4c8982b0@googlegroups.com

On Wed, 6 May 2015 16:05:28 -0700 (PDT), slos wrote:

> Please consider the following simple case :
> 
> package Object is
[...]    
> 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 ?

If you privately override anything for something that is publicly
dynamically polymorphic [~tagged], then that is not any private because you
can [and must] be able to call the overriding body.

The Ada's types model is that Circle.Instance has the function Area anyway.
It is either implemented per inheritance of the parent's type
implementation (if exists) or by providing a new body per overriding. Thus
moving overriding into private changes nothing.

I don't know why it is not allowed. Moreover, it probably would make sense
to move all declarations of overriding into private or even further into
the package body because the fact of overriding is mere an implementation
detail, since the primitive subroutine is there anyway no matter what.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2015-05-07  7:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Dmitry A. Kazakov [this message]
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