comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: OOP in Ada: Alternatives for "protected" scope
Date: Thu, 3 May 2012 18:34:29 -0500
Date: 2012-05-03T18:34:29-05:00	[thread overview]
Message-ID: <jnv4ma$paj$1@munin.nbi.dk> (raw)
In-Reply-To: jnut8r$aqb$1@online.de

"Felix Krause" <flyx@isobeef.org> wrote in message 
news:jnut8r$aqb$1@online.de...
...
> The function Calculate should only be used internally. I do not see a good 
> way to enforce this with Ada: I do not want to move it to P_A's private 
> part, because child classes of A should not be required to be located in 
> sub-packages of P_A. (It's also forbidden for an abstract function to 
> reside in the private part.)
>
> In languages like Java and C#, there is a "protected" scope to cope with 
> this situation. Now of course these languages, unlike Ada, are based on 
> OOP, so it is natural for them to provide class-based visibility scopes. 
> My question is, how would one implement this kind of visibility in Ada?

You gave the answer above, and then said you didn't like it. Well, not 
everything is as we wish it would be!

For the record, Claw used the technique of putting "private" (what you 
called "protected") operations in the private part extensively. Most the 
root types were declared in package Claw (no implementations there) and all 
of the child types were in child packages. It works pretty well, other than 
a gotcha that can happen when deriving from a sibling class (you can't 
override the private operation in that case). We (the ARG) tried to fix that 
for Ada 2012, but the interface mechanism created insurmountable problems 
(another reason I hate interfaces).

                                    Randy.





  parent reply	other threads:[~2012-05-03 23:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 21:27 OOP in Ada: Alternatives for "protected" scope Felix Krause
2012-05-03 21:56 ` Dmitry A. Kazakov
2012-05-04 18:48   ` Felix Krause
2012-05-04 22:00     ` Dmitry A. Kazakov
2012-05-05  8:28       ` Felix Krause
2012-05-05 11:53         ` Dmitry A. Kazakov
2012-05-05  4:33     ` Shark8
2012-05-03 23:34 ` Randy Brukardt [this message]
2012-05-04  1:41 ` BrianG
2012-05-04 10:37 ` Georg Bauhaus
2012-05-04 10:43   ` Georg Bauhaus
2012-05-04 12:10   ` Dmitry A. Kazakov
replies disabled

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