comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Controlled types as interfaces
Date: Fri, 29 Aug 2014 11:01:30 -0400
Date: 2014-08-29T11:01:30-04:00	[thread overview]
Message-ID: <wcc4mwv731x.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: lt5ujt$7g4$1@loke.gir.dk

"Randy Brukardt" <randy@rrsoftware.com> writes:

> The real problem is that some (many?) implementations include 
> implementation-defined components in types Controlled and 
> Limited_Controlled. (For instance, Janus/Ada includes chain components.) 

GNAT used to do that, but actually only heap objects need to be chained,
and the current implementation does not declare the chain links as
components.  Controlled components and stack objects do not get
chained.  A heap object is allocated with some extra space at negative
offsets, where the chain links are stored.

> Interfaces of course don't have any components; thus making 
> Controlled/Limited_Controlled into interfaces would require the back-door 
> implementation of full MI (since it would require adding components to 
> existing types, meaning that the components could not be assumed at a fixed 
> offset). That is a leap too far.
>
> Note that in the OP's example, Janus/Ada does NOT treat the enclosing record 
> as controlled; each individual controlled object (including components) is 
> managed separately. I did it that way to make unwinding an object in the 
> face of exceptions during construction easier (each object is registered as 
> it is constructed, so all successfully constructed objects get finalized and 
> none that failed get finalized). GNAT, OTOH, does treat each object 
                                                   ^ not
> individibly and has to go through some handstands so that objects that 
> aren't constructed aren't finalized.

I think you're missing a "not" there.  Yes, there are some "handstands",
but it's not so bad.  I think the only reason it was so hard to
implement is that it was a re-implementation.  Doing it that way from
the start would not have been so bad (as is often the case).

The compiler generates a "deep_initialize" procedure for each type,
which either fully initializes everything, or else finalizes the parts
that got initialized before an exception.

Rational uses the same method as GNAT.

- Bob

  reply	other threads:[~2014-08-29 15:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20  1:05 Controlled types as interfaces Victor Porton
2014-08-20  1:09 ` Victor Porton
2014-08-20  7:29   ` Dmitry A. Kazakov
2014-08-20 12:49     ` Victor Porton
2014-08-20 13:47       ` Dmitry A. Kazakov
2014-08-21 23:16         ` Randy Brukardt
2014-08-29 15:01           ` Robert A Duff [this message]
2014-08-29 23:54             ` Randy Brukardt
2014-08-20 12:50     ` Victor Porton
2014-08-20 13:38       ` Dmitry A. Kazakov
2014-08-20 13:56       ` Brad Moore
2014-08-21 22:48         ` Randy Brukardt
2014-08-20  1:41 ` Victor Porton
replies disabled

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