From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: OOP in Ada: Alternatives for "protected" scope
Date: Fri, 04 May 2012 12:37:01 +0200
Date: 2012-05-04T12:36:59+02:00 [thread overview]
Message-ID: <4fa3b14b$0$6555$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <jnut8r$aqb$1@online.de>
On 03.05.12 23:27, Felix Krause wrote:
> Now there is some calculation to be done while execution Do_Something which cannot be defined in A.
> (...)
> In languages like Java and C#, there is a "protected" scope to cope with this situation.
There are some O-O solutions.
One solution is outlined by at least on Java guru, and by the Objective-C
programming model in ***step. In short, replace procedural style
with O-O style (sounds odd, but that's really what it does;
the dependence of A/Do_Something on Calculate is an implicit
procedural thing).
with Calculators;
package P_A is
type A is abstract tagged private;
procedure Do_Something (Object : in out A);
--
-- Add your type of computation here to be performed
-- at some time during the execution of Do_Something:
--
procedure Link
(Object : in out A;
Computation: Calculators.Calculator'Class);
private
type Circuits is
access constant Calculators.Calculator'Class;
type A is abstract tagged record
Machine : Circuits;
end record;
end P_A;
If necessary things can be moved further down the package and/or
type hierarchy if the presence of a calculation should be hidden
at the top level.
next prev parent reply other threads:[~2012-05-04 10:37 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
2012-05-04 1:41 ` BrianG
2012-05-04 10:37 ` Georg Bauhaus [this message]
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