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,4608b6f4718e680f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.239.134 with SMTP id vs6mr700242pbc.4.1336439688746; Mon, 07 May 2012 18:14:48 -0700 (PDT) MIME-Version: 1.0 Path: pr3ni551pbb.0!nntp.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Problem in "X (1).Re := X (1).Re + 1" Date: Mon, 7 May 2012 20:14:42 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <13177506.38.1336222539273.JavaMail.geo-discussion-forums@pbtg6> <21452734.731.1336405064187.JavaMail.geo-discussion-forums@ynbv35> <5749033.1275.1336416838264.JavaMail.geo-discussion-forums@pbchd7> <10294366.7.1336426132700.JavaMail.geo-discussion-forums@yngg23> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1336439686 29075 69.95.181.76 (8 May 2012 01:14:46 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 8 May 2012 01:14:46 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-05-07T20:14:42-05:00 List-Id: "Adam Beneschan" wrote in message news:10294366.7.1336426132700.JavaMail.geo-discussion-forums@yngg23... On Monday, May 7, 2012 11:53:58 AM UTC-7, ytomino wrote: > On Tuesday, May 8, 2012 12:37:44 AM UTC+9, Adam Beneschan wrote: ... >So it looks to me like the method you suggest shouldn't be allowed, even in >your own container, > since it would make it impossible to implement Constant_Reference > correctly. It seems to me that his implementation is wrong, since Constant_Reference creates a reference, so it should be impossible for something else to "deallocate" the reference at the same time. (I'm talking about in a hand-created container, I don't think this implementation would be legitimate for Vectors - although I'm not certain). That probably means that Constant_Reference would have to increase the reference count when it is created and decrease it when it is destroyed (specifically the reason why these return record types with discriminants rather than just a bare access value). If that's done, his original example is fine. I'm pretty sure reference counting will work as an implementation using generalized indexing, but it is pretty complicated (as it always is). But I haven't actually tried this in practice, so I could be wrong... Randy.