From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b88383a5d9c51aa0 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!news.teledata-fn.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada-Singleton-Why does it work like this? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <5a7a870c-40e2-4803-8753-0f9cfd2b800f@k2g2000yql.googlegroups.com> Date: Tue, 24 Mar 2009 22:21:03 +0100 Message-ID: <13su65cm8b5ov$.1198qla32cc3i$.dlg@40tude.net> NNTP-Posting-Date: 24 Mar 2009 22:21:04 CET NNTP-Posting-Host: 4b333c4f.newsspool1.arcor-online.net X-Trace: DXC=YggJV2nJ=55LNKYb?b>076ic==]BZ:af>4Fo<]lROoR1^YC2XCjHcb9TPFk8flE511DNcfSJ;bb[5IRnRBaCdQ0S4Ff]0CR=1F0V`^TQe96 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4268 Date: 2009-03-24T22:21:04+01:00 List-Id: On Tue, 24 Mar 2009 12:01:00 -0700 (PDT), patrick.gunia@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. Kazakov http://www.dmitry-kazakov.de