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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,100eb0a59892e906 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!v28g2000hsv.googlegroups.com!not-for-mail From: Sven Newsgroups: comp.lang.ada Subject: Re: How to pass around access types to interfaces? Date: Wed, 29 Oct 2008 05:42:38 -0700 (PDT) Organization: http://groups.google.com Message-ID: <547a5372-f337-4cc4-a05e-953f8a5a70e0@v28g2000hsv.googlegroups.com> References: NNTP-Posting-Host: 93.129.70.76 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1225284158 16635 127.0.0.1 (29 Oct 2008 12:42:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Oct 2008 12:42:38 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v28g2000hsv.googlegroups.com; posting-host=93.129.70.76; posting-account=oTiqeAoAAAAm9MRakyssPfX9BEL3QpPS User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; de-de) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8250 Date: 2008-10-29T05:42:38-07:00 List-Id: On 25 Okt., 16:43, "Martin Krischik" wrote: > Am 24.10.2008, 13:45 Uhr, schrieb Sven : > > > =A0 type My_Interface_Access is access all My_Interface'Class; > > Do you realy need an access type? Read: > > http://en.wikibooks.org/wiki/Ada_Programming/Object_Orientation#The_c... Yes, this needs to be an access type. I need to store references to an object, not the object itself. As far as I understand Ada this can only be done via access types. Declaring a record member of type "My_Interface'Class" is not possible. But even if it was it would store a copy of the object, which would be incorrect and a waste of memory. > If so, does it need to be an access all? Read: > > http://en.wikibooks.org/wiki/Ada_Programming/Types/access#Access_vs._... > > Six month after I switched from C++ to Ada I removed about 80% access =A0 > types from the code I created until then. And from those access types =A0 > which remained more did not need the "all" and I consequently removed tha= t =A0 > as well. "Access all" will allow me to pass references to aliased objects. Right now there is no reason to disallow that, so I'll keep the "all".