comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Enforcing initialization protocol for protected type
Date: Thu, 10 Sep 2009 19:07:53 +0200
Date: 2009-09-10T19:07:53+02:00	[thread overview]
Message-ID: <4aa93269$0$32675$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <afd67283-6369-45ba-b50e-92dc8b8a489c@m38g2000yqd.googlegroups.com>

Maciej Sobczak schrieb:

> This would leave the factory call at the user side (note that in your
> example it was the protected object itself that called the factory),
> which would give more control on factory call parameters and such.
> 
> type State is private;
> type State_Ptr is access State;
> 
> function Make_PO return State_Ptr;
> function Make_PO (Some : T; Parameters : T) return State_Ptr;
> -- ...
> 
> protected type PO (S : State_Ptr) is
> -- ...
> private
>     St : State_Ptr := S;
> end PO;
> 
> so that the typical creation pattern would be:
> 
> X : PO (Make_PO);
> Y : PO (Make_PO (ABC, DEF));
> 
> This, however, opens another question: controlled finalization of
> protected types to release the state object, if it was allocated
> dynamically. Oops.
> But a controlled component of the protected type can take care of
> that.
> Does it make sense?

Yes, state pointer makes sense.

OTOH, you could preserve both, copy semantics for the state if
copying state makes sense and is desirable, and flexible
client side operation of the state factory by defining a two-faced
factory interface:

- one operation is for the protected object. Returns a computed state
  value as a "result" of the factory's operation

- as many operations as desired for computing this inital state.
  This is for the factory operators other that the protected object



  reply	other threads:[~2009-09-10 17:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-07 15:15 Enforcing initialization protocol for protected type Maciej Sobczak
2009-09-07 17:01 ` Georg Bauhaus
2009-09-07 20:19   ` Maciej Sobczak
2009-09-10 17:07     ` Georg Bauhaus [this message]
2009-09-11  5:01     ` AdaMagica
2009-09-11  9:03       ` Dmitry A. Kazakov
2009-09-11 15:25         ` AdaMagica
2009-09-11 16:27           ` Dmitry A. Kazakov
2009-09-11 22:24             ` Randy Brukardt
2009-09-12  8:44               ` Dmitry A. Kazakov
2009-09-10 16:39 ` Per Sandberg
2009-09-14 21:15   ` Adam Beneschan
2009-09-15  0:27     ` Randy Brukardt
replies disabled

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