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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada-Singleton-Why does it work like this? References: <5a7a870c-40e2-4803-8753-0f9cfd2b800f@k2g2000yql.googlegroups.com> In-Reply-To: <5a7a870c-40e2-4803-8753-0f9cfd2b800f@k2g2000yql.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: NNTP-Posting-Host: 173.16.158.68 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1237927670 173.16.158.68 (Tue, 24 Mar 2009 20:47:50 GMT) NNTP-Posting-Date: Tue, 24 Mar 2009 20:47:50 GMT Organization: AT&T ASP.att.net Date: Tue, 24 Mar 2009 20:47:50 GMT Xref: g2news2.google.com comp.lang.ada:5236 Date: 2009-03-24T20:47:50+00:00 List-Id: patrick.gunia@googlemail.com wrote: > Hi all, > 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. I used this code and it all worked as > expected. My problem is, that I don�t ave any idea, why it does...here > is my code: > > package Singleton is > > type Singleton_Type (<>) is tagged limited private; > type Singleton_Access is access all Singleton_Type; > > function return_Single return Singleton_Access; > > procedure setValues(input : in out Singleton_Access; valueIN : > Integer; valueIN2 : Integer); > procedure print_something(input : Singleton_Access); > > > private > type Singleton_Type is tagged limited record > value : Integer; > value2 : Integer; > end record; > > end Singleton; This is a very poor solution to the problem. A much simpler solution is package Singleton is procedure Set (Value_1 : in Integer; Value_2 : in Integer); procedure Print; end Singleton; -- Jeff Carter "We use a large, vibrating egg." Annie Hall 44