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,FREEMAIL_FROM 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!postnews.google.com!h28g2000yqd.googlegroups.com!not-for-mail From: "patrick.gunia@googlemail.com" Newsgroups: comp.lang.ada Subject: Re: Ada-Singleton-Why does it work like this? Date: Wed, 25 Mar 2009 04:55:12 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4c6c592f-6b25-43a0-afe4-d2c9375f7ac7@h28g2000yqd.googlegroups.com> References: <5a7a870c-40e2-4803-8753-0f9cfd2b800f@k2g2000yql.googlegroups.com> <13su65cm8b5ov$.1198qla32cc3i$.dlg@40tude.net> <0c060dc1-ee16-48cd-89cf-5f4f02185ee8@c11g2000yqj.googlegroups.com> NNTP-Posting-Host: 78.34.66.221 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1237982112 3571 127.0.0.1 (25 Mar 2009 11:55:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 25 Mar 2009 11:55:12 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h28g2000yqd.googlegroups.com; posting-host=78.34.66.221; posting-account=D7TrwwoAAAAVyN71CASRiSp392RIjlsB User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.64 (Windows NT 6.0; U; de) Presto/2.1.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5266 Date: 2009-03-25T04:55:12-07:00 List-Id: On 25 Mrz., 12:46, Ludovic Brenta wrote: > On Mar 25, 11:57=A0am, "patrick.gu...@googlemail.com" > > > > > > wrote: > > Yet another question, if my Singleton_Type is unconstrained, why does > > Ada allow creating Access-Types to unconstrained types allowing to > > access there record-properties, while not allowing to create an > > instance of Singleton_Type directly? I thought that Ada demands a > > declaration of an instance before creating an Access-Type to access > > it? Maybe I=B4m mixing in C++, but if I declare a pointer in C++ I > > either have to create a new instance using "new" in heap-memory where > > the pointer points to or I have to use references and then let the > > pointer point to a reference. In both cases I first have to create an > > object and then let the pointer point to it. When I use access types > > in Ada in my example it=B4s possible to create a pointer to a class > > which can=B4t be instantiated, because it is unconstrained. Though it > > works to access the record-properties using the access-type. Could > > anyone tell me what I=B4m getting wrong concerning Ada? > > > Thank you! > > If you want to declare an access type, you do not need an instance; > you only need a type, which may be unconstrained: > > type T (<>) is limited private; > type Access_T is access T; -- OK > > If you want an access *value*, then you do need an object; either one > from a storage pool, or a pre-existing one: > > Access_Value : Access_T :=3D new T'(...); > -- storage pool. Possible only in the package declaring T, since T is > private. > > Other_Access_Value : Access_T :=3D Access_Value; -- possible anywhere > > Neither Access_Value nor Other_Access_Value allow you to see the > components of T because T is private. > > -- > Ludovic Brenta. Alright, I mixed this up, you=B4re right. Slowly all pieces make sense to me and now I=B4m starting to get the differences and why the Singleton-implementation works... Thank you for your help!