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: a07f3367d7,5d4ade2fd8fd67c6 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Legit Warnings or not Date: Thu, 28 Jul 2011 11:10:09 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <531193e0-3305-4292-9ed8-0176226c1d00@x12g2000yql.googlegroups.com> <1rx6dwrxmc81p.eazb4fjqztox$.dlg@40tude.net> <1hi6gva8jhf7o.tq1yp29jn3qu.dlg@40tude.net> <1a259uy924xfx.1ajyj4ot8cv26.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1311865810 10175 192.74.137.71 (28 Jul 2011 15:10:10 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 28 Jul 2011 15:10:10 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:veCFT6lWOQx3EeG6oJnTARiojOw= Xref: g2news2.google.com comp.lang.ada:21371 Date: 2011-07-28T11:10:09-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Thu, 28 Jul 2011 10:22:28 -0400, Robert A Duff wrote: > >> "Dmitry A. Kazakov" writes: >> >>> On Wed, 27 Jul 2011 19:37:55 -0500, Randy Brukardt wrote: >> >>>> All of the other things are high-level concepts which work the same whether >>>> or not the objects are contiguous. ":=" and "=" are defined in terms of the >>>> subcomponents, >>> >>> which is ambiguous when components are referential. Does ":=" copy the >>> reference or the target object? >> >> There's no ambiguity. "X := Y;" copies all components of Y. >> If the compiler chooses to implement some of those components >> via some sort of indirection, then ":=" will need to do a deep copy, >> in general. > > So the compiler is not allowed to do reference counting with cloning upon > update? Sure it is. The compiler can do anything it likes, so long as the external behavior obeys the RM. That's the "as if" rule. Which isn't really a rule -- more of a "meta rule" which applies to all higher-level programming language definitions, whether the language definition says so or not. That's the difference between an assembly language and a higher-level language -- the "as if" meta-rule doesn't apply to assembly languages. So yes, the compiler can do the deep copy in a lazy fashion, as you suggest. There are lots of other things the compiler can do. For example: X : constant String := Func(...); Y : constant String := X; The compiler can allocate X and Y (or parts of them) at the same memory location. And X'Address could equal Y'Address. Without the "constant"s, it could still do that optimization, if it can prove there are no modifications to X or Y. Or, as you say, if it detects such modifications at run time. (But if they were aliased, then X'Access cannot equal Y'Access.) >> The indirection must be invisible (except, as you mentioned, for >> low-level stuff like 'Size and Unchecked_Conversion). > > I.e. it leaks. Right. Somebody famous said "all abstractions leak". And chapter 13 is where you'll find a lot of leaks. But that's OK, because the semantics of 'Size and U_D aren't really nailed down anyway. (Well, 'Size is nailed down for scalar subtypes, but we're talking about cases where the compiler might want to introduce extra levels of indirection.) - Bob