From: Martin <martin.dowie@btopenworld.com>
Subject: Re: Package's private parts and protected types
Date: Mon, 8 Feb 2010 00:30:12 -0800 (PST)
Date: 2010-02-08T00:30:12-08:00 [thread overview]
Message-ID: <e89844fd-9f16-40a1-821a-177d4f02caf4@o3g2000yqb.googlegroups.com> (raw)
In-Reply-To: 7ff3810f-3ee3-4f39-a54c-933ad7d0655c@36g2000yqu.googlegroups.com
On Feb 8, 4:30 am, Hibou57 (Yannick Duchêne)
<yannick_duch...@yahoo.fr> wrote:
> Hi all out there,
>
> Whenever a protected type is declared, all of its specification has to
> be defined at once and not private stuff can be delay (like "type ...
> is private" would allow). If this protected type is to hold something
> which is not to be public, the only way to do as far I'm able to do,
> is to wrap it in a private type as a record component.
>
> package P
>
> type A_Type is limited private;
> -- Must be limited, to be able to hold a limited component.
>
> function Value (A : A_Type) return Value_Type;
> -- Value_Type defined somewhere else.
>
> procedure Do_Something (A : in out A_Type);
> -- Potentially blocking.
> -- Obviously, there are comments to assert such things,
> -- but I would prefer it to be formally stated.
>
> private
>
> protected type B_Type is
> -- Cannot move it in the public part, due
> -- to a feature (Set_Value) which must not be public.
> function Value return Value_Type;
> -- Accessed via the corresponding method on A_Type.
> procedue Set_Value (New_Value : in Value_Type);
> -- The A_Type does not have such a corresponding
> -- method : we want it to remains private.
> procedure Do_Something;
> -- Accessed via the corresponding method on A_Type.
> -- B_Type being protected, this means this is
> -- a potentially blocking operation.
> end B_Type;
>
> type A_Type is limited record
> B : B_Type;
> end record;
>
> end P;
>
> Then, implementation of methods on A_Type will then simply pass
> control to the corresponding ones of its B component. All of this,
> just to hide something which is not to be part of the public
> specification.
>
> I don't like it, because it does not any more publicly shows that
> things relies on a protected object.
>
> Was this a desired consequence when this part of Ada was designed ?
>
> Do someone know a reason ?
>
> Is there something I'm doing here I should not do ?
This is true of task types too.
We take the view that if something was a task/protected or not should
be hidden from a user (e.g. we may change the behaviour from being
task based/not protected, so we abstract away that information). The
associated 'rule' for callers is that they can't assume that calls to
any operation don't block - but that's true of calling pretty much any
package anyway.
I wonder if there is room for "pragma (Not_)Blocking"?...Not just as a
visual aid but maybe it could also be used extend the usage of "pragma
Detect_Blocking" to wrappers for "foreign languages".
Cheers
-- Martin
next prev parent reply other threads:[~2010-02-08 8:30 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-08 4:30 Package's private parts and protected types Hibou57 (Yannick Duchêne)
2010-02-08 8:30 ` Martin [this message]
2010-02-08 9:11 ` Hibou57 (Yannick Duchêne)
2010-02-08 10:10 ` Alex R. Mosteo
2010-02-08 10:46 ` Hibou57 (Yannick Duchêne)
2010-02-09 14:55 ` Alex R. Mosteo
2010-02-08 10:20 ` Dmitry A. Kazakov
2010-02-08 10:54 ` Hibou57 (Yannick Duchêne)
2010-02-08 10:58 ` Hibou57 (Yannick Duchêne)
2010-02-08 11:01 ` Dmitry A. Kazakov
2010-02-08 13:19 ` Georg Bauhaus
2010-02-08 15:17 ` Robert A Duff
2010-02-08 16:15 ` (see below)
2010-02-08 20:44 ` Robert A Duff
2010-02-08 22:00 ` Hibou57 (Yannick Duchêne)
2010-02-09 5:48 ` AdaMagica
2010-02-09 14:56 ` Robert A Duff
2010-02-10 2:29 ` Randy Brukardt
2010-02-11 23:46 ` Robert A Duff
2010-02-12 1:29 ` Randy Brukardt
2010-02-11 23:53 ` Robert A Duff
2010-02-12 1:10 ` Randy Brukardt
2010-02-10 16:05 ` Adam Beneschan
2010-02-10 20:17 ` sjw
2010-02-12 0:05 ` Robert A Duff
2010-02-12 11:07 ` Stephen Leake
2010-02-12 15:01 ` Robert A Duff
2010-02-13 8:00 ` Stephen Leake
2010-02-09 9:04 ` stefan-lucks
2010-02-08 17:11 ` Jeffrey R. Carter
2010-02-08 14:56 ` Robert A Duff
2010-02-08 15:36 ` Dmitry A. Kazakov
2010-02-08 16:06 ` Robert A Duff
2010-02-08 17:46 ` Jean-Pierre Rosen
2010-02-08 20:39 ` Robert A Duff
2010-02-08 21:54 ` Hibou57 (Yannick Duchêne)
2010-02-08 21:50 ` Hibou57 (Yannick Duchêne)
2010-02-08 22:04 ` Hibou57 (Yannick Duchêne)
2010-02-09 10:58 ` Hibou57 (Yannick Duchêne)
2010-02-09 14:47 ` Robert A Duff
2010-02-09 19:34 ` Hibou57 (Yannick Duchêne)
2010-02-09 20:19 ` Hibou57 (Yannick Duchêne)
2010-02-09 23:29 ` Robert A Duff
2010-02-10 2:39 ` Randy Brukardt
2010-02-10 5:12 ` Hibou57 (Yannick Duchêne)
2010-02-10 7:17 ` Hibou57 (Yannick Duchêne)
2010-02-10 16:09 ` Robert A Duff
2010-02-10 22:21 ` Hibou57 (Yannick Duchêne)
2010-02-11 0:48 ` Robert A Duff
2010-02-09 0:48 ` Randy Brukardt
2010-02-09 12:43 ` Hibou57 (Yannick Duchêne)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox