comp.lang.ada
 help / color / mirror / Atom feed
From: george.priv@gmail.com
Subject: Re: How to return an empty aggregate
Date: Fri, 4 Apr 2008 16:58:36 -0700 (PDT)
Date: 2008-04-04T16:58:36-07:00	[thread overview]
Message-ID: <db3cd468-6de5-4014-8127-5056de6e208e@m3g2000hsc.googlegroups.com> (raw)
In-Reply-To: e8256040-917c-4794-9e02-387820de12d1@a70g2000hsh.googlegroups.com

On Apr 4, 4:35 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> On 4 Kwi, 17:38, george.p...@gmail.com wrote:
>
> > Good example is a factory.  Should it have a
> > mechanism to register-unregister itself?
>
> Not necessarily. I might be as well selected at startup time by some
> other entity (in which case it is also a strategy).
>
> > In addition such
> > objects make sense in singleton form
>
> Yes and no.
> Yes, because it does not make any sense to destroy them and create
> again.
> No, because it is *not harmful* to destroy and create them again (see
> also the monostate pattern):
>
> F : Factory'Class := Make_Funny_Factory;
> Obj : Object := F.Make_Object;
>
> Above, factory F is a transient entity that is used just to create one
> object. It might be a singleton as well, but does not have to.

To me it seems that simple callback will be much more simple and clear
way to achieve the same result.

type Make_Object is access function(Context: Contect_Type) return
Object;

Obj : object := Make_My_Object(Some_Context_Selector);


>
> > and likely involve some sort of
> > guarding mutexes or be implemented as protected or tasks.
>
> If it's stateless, then it does not need any protection - there is
> nothing to protect.

except for reenterance that in most of cases matter for that type of
objects.

>
> > BTW in C++
> > empty factory class will be fine due to implied constructor/
> > destructor.
>
> The empty factory class will be fine in Ada as well.
>
> --
> Maciej Sobczak *www.msobczak.com*www.inspirel.com




  reply	other threads:[~2008-04-04 23:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01 11:58 How to return an empty aggregate Maciej Sobczak
2008-04-01 12:54 ` Anh Vo
2008-04-01 17:18   ` Adam Beneschan
2008-04-02  7:16     ` Maciej Sobczak
2008-04-01 13:34 ` Dmitry A. Kazakov
2008-04-01 15:00 ` Robert A Duff
2008-04-02  7:19   ` Maciej Sobczak
2008-04-03  5:02     ` george.priv
2008-04-03  9:09       ` Maciej Sobczak
2008-04-04 15:38         ` george.priv
2008-04-04 20:35           ` Maciej Sobczak
2008-04-04 23:58             ` george.priv [this message]
2008-04-05 13:48               ` Maciej Sobczak
2008-04-05 16:04                 ` george.priv
2008-04-05 21:14                   ` Maciej Sobczak
2008-04-05 22:36                     ` george.priv
2008-04-06 19:53                       ` Maciej Sobczak
2008-04-06  7:00                     ` george.priv
2008-04-06 20:04                       ` Maciej Sobczak
2008-04-07 20:23                         ` george.priv
replies disabled

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