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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.191.225 with SMTP id hb1mr1503597pbc.5.1336222619810; Sat, 05 May 2012 05:56:59 -0700 (PDT) Path: pr3ni6863pbb.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: ytomino Newsgroups: comp.lang.ada Subject: Problem in "X (1).Re := X (1).Re + 1" Date: Sat, 5 May 2012 05:55:39 -0700 (PDT) Organization: http://groups.google.com Message-ID: <13177506.38.1336222539273.JavaMail.geo-discussion-forums@pbtg6> NNTP-Posting-Host: 114.145.61.184 Mime-Version: 1.0 X-Trace: posting.google.com 1336222619 26959 127.0.0.1 (5 May 2012 12:56:59 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 5 May 2012 12:56:59 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=114.145.61.184; posting-account=Mi71UQoAAACnFhXo1NVxPlurinchtkIj User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-05-05T05:55:39-07:00 List-Id: This is a thought experiment. First, in RM 4.1.6: * when the generalized_indexing is used within a primary where a name denoting a constant is permitted. This means declare package V is new Vectors (Complex); X : V.Vector; begin X (1).Re := X (1).Re + 1; end; is interpreted as declare package V is new Vectors (Complex); X : V.Vector; begin Reference (X, 1).Element.all.Re := Constant_Reference (X, 1).Element.all.Re + 1; end; Is this OK? If this is the truth, and if Vectors is implemented by reference-counting. (I don't know copy-on-write is permitted in Ada.Containers.Vectors. Otherwise, please assume my original container like Vectors.) Well then... May a next eval-order problem be caused or not? 1. eval "Constant_Reference (X, 1)" => get an accessor pointing to shared data. (reference counter > 1) 2. eval "Reference (X, 1)" => do copy-on-write, and get an accessor pointing to new unshared data. 3. eval ".Element.all.Re" in right side => access *old* shared data. <- !!!! 4. eval ".Element.all.Re" in left side => access new data. 5. eval + 1 => calculate old data + 1. 6. eval assignment => store the result into new data. (Real compiler usually does not generate the strange order such as this. But "arbitrary order" is spelled out in RM 5.2.) Of course, the result is same if shared data is alive. However, on the worst case, the other task can deallocate shared data during from 1 to 3. Or, if the element type is controlled type or havs access value. What do you think? Thanks.