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!news4.google.com!feeder.news-service.com!news2.euro.net!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng1.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 25 Mar 2009 12:26:40 +0100 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.21 (Macintosh/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> <9a5fb100-c38d-45f6-a482-1c67b26c5866@z15g2000yqm.googlegroups.com> <19a1c6cf-4e4d-402c-902d-3ea2055b4779@c11g2000yqj.googlegroups.com> In-Reply-To: <19a1c6cf-4e4d-402c-902d-3ea2055b4779@c11g2000yqj.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <49ca14f1$0$30231$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 25 Mar 2009 12:26:41 CET NNTP-Posting-Host: ebf778aa.newsspool1.arcor-online.net X-Trace: DXC=[RE@UbE5m1F0YVY]kmLTlDic==]BZ:afN4Fo<]lROoRA^YC2XCjHcbICW9^O>US0XI;9OJDO8_SKFNSZ1n^B98iJicFK?R8kU1F X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:5260 Date: 2009-03-25T12:26:41+01:00 List-Id: patrick.gunia@googlemail.com schrieb: > Still I don�t get how the unconstrained type limits the > number of instances to 1. It does, but outside package Singleton only. The (<>) forces initialization. The "limited" part prevents assignment (thus copying). The type is private. Any object to be created in whichever way must be initialized because of (<>). Initialization is not possible outside the package because Singleton_Type has discriminants unknown outside the package. Also, any object of the public Singleton_Type cannot be assigned a new value (because it is limited). The only place where objects of type Singleton_Type can be created is where the full definition of type Singleton_Type is visible. The only way to get a reference to the object is through function return_Single. This function always returns the same access value, hence clients of package Singleton always use the same (invisible) object.