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,4608b6f4718e680f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.197.35 with SMTP id ir3mr2605304pbc.6.1336561516842; Wed, 09 May 2012 04:05:16 -0700 (PDT) Path: pr3ni5889pbb.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: ytomino Newsgroups: comp.lang.ada Subject: Re: Problem in "X (1).Re := X (1).Re + 1" Date: Wed, 9 May 2012 04:03:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: <28665682.73.1336561402311.JavaMail.geo-discussion-forums@pbnh4> 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> <15071427.1562.1336550750742.JavaMail.geo-discussion-forums@pbcia3> NNTP-Posting-Host: 118.8.128.51 Mime-Version: 1.0 X-Trace: posting.google.com 1336561516 3467 127.0.0.1 (9 May 2012 11:05:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 9 May 2012 11:05:16 +0000 (UTC) In-Reply-To: <15071427.1562.1336550750742.JavaMail.geo-discussion-forums@pbcia3> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=118.8.128.51; posting-account=Mi71UQoAAACnFhXo1NVxPlurinchtkIj User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-05-09T04:03:22-07:00 List-Id: On Wednesday, May 9, 2012 5:05:50 PM UTC+9, ytomino wrote: > > I still don't think it's impossible. > How about inserting the copy-on-write code into Constant_Reference? I reconsidered. X : Vector; -- insert items into X Ref1 := V.Constant_Reference (X, 1); -- reference counter = 1 Z := X; -- reference counter = 2 Ref2 := V.Constant_Reference (X, 2); -- (E) what should it do? If simple copy-on-write is executed at E, Ref1.Element will be an old value. Probably, Reference/Constant_Reference should disable the container from increasing the reference counter. X : Vector; -- insert items into X Ref1 := V.Constant_Reference (X, 1); -- reference counter = 1, and locking it Z := X; -- deep copy, keeping reference counter = 1 Ref2 := V.Constant_Reference (X, 2); -- OK Otherwise, more complicated mechanism like ownership control is required.