comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Legit Warnings or not
Date: Thu, 28 Jul 2011 11:10:09 -0400
Date: 2011-07-28T11:10:09-04:00	[thread overview]
Message-ID: <wcc39hqxwz2.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1a259uy924xfx.1ajyj4ot8cv26.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Thu, 28 Jul 2011 10:22:28 -0400, Robert A Duff wrote:
>
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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



  reply	other threads:[~2011-07-28 15:10 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 22:30 Legit Warnings or not Anh Vo
2011-07-20 23:16 ` Robert A Duff
2011-07-21 18:43   ` Anh Vo
2011-07-23  0:26   ` Randy Brukardt
2011-07-23 14:26     ` Robert A Duff
2011-07-21  2:37 ` Jeffrey Carter
2011-07-21  9:50   ` Brian Drummond
2011-07-21 14:39     ` Dmitry A. Kazakov
2011-07-23  0:36       ` Randy Brukardt
2011-07-23  9:03         ` Dmitry A. Kazakov
2011-07-23 11:07           ` Simon Wright
2011-07-23 11:21             ` Dmitry A. Kazakov
2011-07-26 21:25           ` Randy Brukardt
2011-07-27  7:45             ` Dmitry A. Kazakov
2011-07-28  0:37               ` Randy Brukardt
2011-07-28  9:22                 ` Dmitry A. Kazakov
2011-07-28 14:22                   ` Robert A Duff
2011-07-28 14:41                     ` Dmitry A. Kazakov
2011-07-28 15:10                       ` Robert A Duff [this message]
2011-07-28 17:05                         ` Dmitry A. Kazakov
2011-07-28 23:32                           ` Randy Brukardt
2011-07-28 23:48                   ` Randy Brukardt
2011-07-29  6:57                     ` Simon Wright
2011-07-29 18:56                       ` Jeffrey Carter
2011-07-30  0:13                       ` Randy Brukardt
2011-07-29  7:41                     ` Dmitry A. Kazakov
2011-07-30  0:17                       ` Randy Brukardt
2011-07-30  8:27                         ` Dmitry A. Kazakov
2011-08-01 22:12                           ` Randy Brukardt
2011-08-02 10:01                             ` Dmitry A. Kazakov
2011-08-02 21:30                               ` Randy Brukardt
2011-08-03  9:01                                 ` Dmitry A. Kazakov
2011-08-03 20:35                                   ` Randy Brukardt
2011-08-04  8:11                                     ` Dmitry A. Kazakov
2011-08-05 23:57                                       ` Randy Brukardt
2011-08-06  8:23                                         ` Dmitry A. Kazakov
2011-08-08 21:30                                           ` Randy Brukardt
2011-07-23 14:32         ` Robert A Duff
2011-07-26 21:32           ` Randy Brukardt
2011-07-21 15:28     ` Adam Beneschan
2011-07-21 15:41       ` Robert A Duff
2011-07-21 20:12         ` Adam Beneschan
2011-07-23  0:31           ` Randy Brukardt
2011-07-21 17:40     ` Jeffrey Carter
2011-07-21 21:30       ` Brian Drummond
2011-07-21 21:54         ` Adam Beneschan
2011-07-22 10:16           ` Brian Drummond
2011-07-22 14:54             ` Adam Beneschan
2011-07-23  0:46             ` Randy Brukardt
2011-07-23  0:42         ` Randy Brukardt
2011-07-23  9:20           ` Niklas Holsti
2011-08-04  5:56             ` David Thompson
2011-07-23  9:24           ` Dmitry A. Kazakov
2011-07-23 12:36           ` Brian Drummond
2011-07-21 15:13   ` Robert A Duff
2011-07-23  0:52     ` Randy Brukardt
2011-07-23 14:48       ` Robert A Duff
2011-07-21 14:17 ` anon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox