comp.lang.ada
 help / color / mirror / Atom feed
From: "patrick.gunia@googlemail.com" <patrick.gunia@googlemail.com>
Subject: Re: Ada-Singleton-Why does it work like this?
Date: Wed, 25 Mar 2009 03:07:18 -0700 (PDT)
Date: 2009-03-25T03:07:18-07:00	[thread overview]
Message-ID: <fb214c6f-a36d-4f8e-a633-33f8c6ee92d6@j38g2000yqa.googlegroups.com> (raw)
In-Reply-To: 13su65cm8b5ov$.1198qla32cc3i$.dlg@40tude.net

On 24 Mrz., 22:21, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Tue, 24 Mar 2009 12:01:00 -0700 (PDT), patrick.gu...@googlemail.com
> wrote:
>
> > I´m currently working on implementing several design patterns in Ada,
> > and I found some code concerning the Singleton-pattern when searching
> > through the posts of this group.
>
> A side note. Singleton is not needed in Ada. Arguably the only valid use of
> singleton is execution of some piece of code once upon elaboration of some
> module. In Ada this is achieved by putting elaboration code put in the body
> of corresponding package:
>
> package body Foo is
>    ... -- Implementation of the entities declared in Foo
>
> begin
>    ... -- Elaboration code, executed once
> end Foo;
>
> A related, though a bit suspicious use of singleton is when it encapsulates
> a managed global state is achieved again by a package. See the post of
> Jeffrey Carter that illustrates this case.
>
> The bottom lime. Singleton pattern is used only in the languages which bind
> visibility to type. In Ada visibility is bound directly to the module
> (package), which eliminates any need in this pattern.
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

Maybe I´m getting something wrong, but from my point of view,
Singleton offers more possibilities than just the execution of some
code on elaboration of some module.I like the dynamic version Ludovic
described. It also offers the possibility to change the number of
instances later on and thus increases the adaptability. When you say
that Singleton isn´t necessary in Ada this might come from the fact
that it can´t be implemented as in other languages, though using such
a construct might increase readability of the code.



  reply	other threads:[~2009-03-25 10:07 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-24 19:01 Ada-Singleton-Why does it work like this? patrick.gunia
2009-03-24 19:10 ` Pascal Obry
2009-03-24 20:47 ` Jeffrey R. Carter
2009-03-25  0:10   ` Martin
2009-03-25  0:41     ` Jeffrey R. Carter
2009-03-25  9:30     ` Dmitry A. Kazakov
2009-03-26  8:55       ` Martin
2009-03-26  9:28         ` Dmitry A. Kazakov
2009-03-26 13:39           ` Maciej Sobczak
2009-03-26 14:07             ` Georg Bauhaus
2009-03-26 14:33               ` Dmitry A. Kazakov
2009-03-26 15:22                 ` Georg Bauhaus
2009-03-26 16:31                   ` Dmitry A. Kazakov
2009-03-26 14:28             ` Dmitry A. Kazakov
2009-03-26 22:00               ` Maciej Sobczak
2009-03-27 10:02                 ` Dmitry A. Kazakov
2009-03-25 22:29   ` sjw
2009-03-24 20:52 ` Ludovic Brenta
2009-03-25  9:59   ` patrick.gunia
2009-03-25 10:29     ` Jean-Pierre Rosen
2009-03-25 11:26     ` Georg Bauhaus
2009-03-25 11:49       ` patrick.gunia
2009-03-29  7:29     ` Jacob Sparre Andersen
2009-03-24 21:21 ` Dmitry A. Kazakov
2009-03-25 10:07   ` patrick.gunia [this message]
2009-03-25 10:57     ` patrick.gunia
2009-03-25 11:40       ` Georg Bauhaus
2009-03-25 11:46       ` Ludovic Brenta
2009-03-25 11:55         ` patrick.gunia
2009-03-25 14:10         ` patrick.gunia
2009-03-25 14:40           ` Ludovic Brenta
2009-03-25 15:16             ` Adam Beneschan
2009-03-25 15:19             ` patrick.gunia
2009-03-25 16:52               ` Georg Bauhaus
2009-03-25 11:10     ` Dmitry A. Kazakov
2009-03-25 11:37       ` patrick.gunia
2009-03-25 12:07         ` Ludovic Brenta
2009-03-25 15:00         ` Robert A Duff
2009-03-25 11:17     ` Jean-Pierre Rosen
2009-03-26  9:04       ` Martin
2009-03-25 11:38     ` Ludovic Brenta
replies disabled

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