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: g2news1.google.com!postnews.google.com!y13g2000yqn.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: Ada-Singleton-Why does it work like this? Date: Thu, 26 Mar 2009 01:55:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <5a7a870c-40e2-4803-8753-0f9cfd2b800f@k2g2000yql.googlegroups.com> <6d2b2c67-22fb-4283-87ab-58357e47d5ca@v39g2000yqm.googlegroups.com> NNTP-Posting-Host: 20.133.0.8 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1238057746 23669 127.0.0.1 (26 Mar 2009 08:55:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 26 Mar 2009 08:55:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y13g2000yqn.googlegroups.com; posting-host=20.133.0.8; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:4327 Date: 2009-03-26T01:55:46-07:00 List-Id: On 25 Mar, 09:30, "Dmitry A. Kazakov" wrote: > On Tue, 24 Mar 2009 17:10:11 -0700 (PDT), Martin wrote: > > On Mar 24, 8:47=A0pm, "Jeffrey R. Carter" > >> This is a very poor solution to the problem. A much simpler solution i= s > > >> package Singleton is > >> =A0 =A0 procedure Set (Value_1 : in Integer; Value_2 : in Integer); > > >> =A0 =A0 procedure Print; > >> end Singleton; > > > But you can not derive a class from this: > > Firstly you can. There are child packages in Ada, they are equivalent to > derivation. > > Secondly, you may not because it is a singleton. A derived variant would = be > meaningless without making an instance of, which would be *another* > instance of now non-singleton. Unless you use the "tagged type" version...and that would be ok, as a type is not an object. So you would have something like: package Singletons is type Singleton ...; function Get_Instance return Singleton; end Singletons; package Singletons.Thread_Safe is type Thread_Safe_Singleton is new Singleton ...; function Get_Instance return Thread_Safe_Singleton; end Singletons.Thread_Safe; But only one object of either of these types could be instantiated. Cheers -- Martin