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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Controlled types as interfaces Date: Thu, 21 Aug 2014 18:16:05 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <17zg1do470nci.15209dgoz3ktk.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1408662976 7684 69.95.181.76 (21 Aug 2014 23:16:16 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 21 Aug 2014 23:16:16 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:21866 Date: 2014-08-21T18:16:05-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:imjh3cg11wdr$.1hslpo3a68yxi.dlg@40tude.net... > On Wed, 20 Aug 2014 15:49:36 +0300, Victor Porton wrote: ... >> As there is no problem that this record becomes controlled, there are no >> reason not to make Q controlled despite of T was non-controlled. > > It depends on concrete implementations, e.g. some might require the type > tag being at the record's first address. That's not exactly the problem, as Ada allows types with conflicting representation clauses to be rejected. (This particular problem can already happen for interfaces, so there are rules to handle it.) 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.) 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 individibly and has to go through some handstands so that objects that aren't constructed aren't finalized. Randy.