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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no 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!proxad.net!feeder1-2.proxad.net!news.mixmin.net!news2.arglkargh.de!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Self pointer in limited record Date: Fri, 7 Sep 2007 20:36:08 -0500 Organization: Jacob's private Usenet server 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: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1189215194 23538 69.95.181.76 (8 Sep 2007 01:33:14 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 8 Sep 2007 01:33:14 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:1812 Date: 2007-09-07T20:36:08-05:00 List-Id: "Jean-Pierre Rosen" wrote in message news:jfsjbf.smp.ln@hunter.axlog.fr... > 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. I'd call it rote perhaps, but it is nowhere near automatic. Changing the references of the globals alone can take hours (there is no prefix to change with an automatic tool, and the names typically conflict with other entities). Moreover, you also have to change the comments to match, and especially the error handling (which often will need more detailed exception information in order to be able to tell which instances are involved). If you think it is so easy, I have a number of packages (and the programs that use them) that need such an update. Where should I send the source?? ;-) After all, most programming is rote, but very little can really be automated. Randy.