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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,eca91508b02e7e97 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.astraweb.com!border2.a.newsrouter.astraweb.com!hwmnpeer01.ams!news.highwinds-media.com!feeder1.cambrium.nl!feed.tweaknews.nl!news.netcologne.de!nhp.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Amount of copying on returned constant objects Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <5dfsfnF1qav8bU1@mid.individual.net> <46730bf5$0$23134$9b4e6d93@newsspool1.arcor-online.net> <5dntd6F35jc57U1@mid.individual.net> <4676C27D.2050608@obry.net> <5dpp8pF35116bU1@mid.individual.net> Date: Wed, 20 Jun 2007 09:34:06 +0200 Message-ID: <13ds63hyo3h7z.dllpoyf4w28p$.dlg@40tude.net> NNTP-Posting-Date: 20 Jun 2007 09:31:17 CEST NNTP-Posting-Host: e6d4a884.newsspool4.arcor-online.net X-Trace: DXC=glcE6HEfU7N02Sh8E_NfIA4IUKATUoCDNcfSJ;bb[EFCTGGVUmh?DLK[5LiR>kgBDInfhZnA>mH X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:16255 Date: 2007-06-20T09:31:17+02:00 List-Id: On Tue, 19 Jun 2007 16:33:26 -0500, Randy Brukardt wrote: > "Alex R. Mosteo" wrote in message > news:5dpp8pF35116bU1@mid.individual.net... >> Randy Brukardt wrote: > ... >>> What really would help would be a way for the container to know when the >>> access was destroyed, but there isn't any obvious way to do that in Ada. >> >> I guess then that some reference counting companion type (or maybe making >> Cursors tagged and more heavyweight) was discarded because the distributed >> overhead? > > Cursors can be tagged if the implementation so choses, but that doesn't have > an effect on the element access problem. For that you need something that > allows direct dereferencing, and in Ada as it stands, that can only be an > access type. > > Having a companion type would work if it was impossible to separate the > access from the reference counter. But there is no way in Ada to have a > visible access type that cannot be assigned out of its surrounding wrapper. > (Which is why I said that Dmitry would say that redefinition of ".all" for a > private type could solve the problem.) Actually it would be only a half of the solution. The access type for which .all gets overridden is an implementation of the cursor. The public view of, should be a derived type of Element: --- This is far not Ada! type Cursor is new Element with private; -- I can do with a Cursor anything I could do with an Element function Get (Collection : Container, What : Key) return Cursor; -- Factory private type Cursor is access Element with interface Element; -- Privately Cursor is an access type that implements the interface -- of Element. It could be also a fat record rather than access, with -- a reference to the container and an index within. Whatever, it -- cannot be seen from outside. function Is_Nice (Item : Cursor) return Boolean; -- Implementation of Element's interface by Cursor -- + Getter/Setter, of course Here the referential nature of Cursor is hidden and Cursor is a full substitute of Element -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de