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,5c89acd494ea9116 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Self pointer in limited record Date: Tue, 04 Sep 2007 17:09:36 +0200 Organization: Adalog Message-ID: References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <1188578849.187422.280620@50g2000hsm.googlegroups.com> <9fy1xoukz1e3$.h574sqmiauri$.dlg@40tude.net> <46d968ee$0$30368$9b4e6d93@newsspool4.arcor-online.net> <137iu0lr82dtb$.wqy3zjz2vr9q.dlg@40tude.net> <6u642u4cyw.fsf@hod.lan.m-e-leypold.de> <1188917721.390096.265690@r29g2000hsg.googlegroups.com> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1188921686 6999 195.25.228.57 (4 Sep 2007 16:01:26 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 4 Sep 2007 16:01:26 +0000 (UTC) User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) In-Reply-To: <1188917721.390096.265690@r29g2000hsg.googlegroups.com> Xref: g2news2.google.com comp.lang.ada:1735 Date: 2007-09-04T17:09:36+02:00 List-Id: Adam Beneschan a �crit : > The trouble is, I can think of several occasions in which I assumed an > object could only have one instance---and then later found reason to > wish I had written it so that there could be two. > > No, this doesn't happen in all cases. But it seems to me it happens > often enough that one should carefully examine any assumption that > there can be only one instance. Or be prepared to go back and make > some major changes later. > If you implemented your singleton as a package, it is quite an automatic transformation: - Add a (normally private) type to the specification - Implement it as a record whose components are all the global (state) variables of the package - Add a parameter of this type to every subprogram provided by the package, and in the bodies, change the references to the global variables to the corresponding field of the new parameter. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr