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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Quick question regarding limited type return syntax Date: Mon, 4 Aug 2014 14:43:42 +0200 Organization: cbb software GmbH Message-ID: <1ge2ly0v5yk8d.j8pd98xg0o8v.dlg@40tude.net> References: <166aaec5-5e9c-40e0-9b07-9b9c7d5f7f33@googlegroups.com> <16a6846f-2964-438a-ab9b-2029075f7924@googlegroups.com> <20m59uxjlygw$.2mpabkt469vp.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ot/DC7n2aCvt5pcTM4dZCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:21441 Date: 2014-08-04T14:43:42+02:00 List-Id: On Mon, 04 Aug 2014 12:24:19 +0300, Niklas Holsti wrote: > Controlled types in Ada provide hooks (Initialize/Finalize/Adjust) that > can be used as constructors and destructors, Not really. The problem is that they hook too late to be specific type constructor and too early for a specific type destructor. This is why you can dispatch from there. The problem arise when you attempt both: use Initialize as if it were a specific constructor hook and dispatch from it. > I don't agree that dispatching on a controlled object should be illegal > until the Initialize operation on that object has been completed. Then you cannot call Initialize a constructor's hook. These two are mutually exclusive. You can dispatch not before all specific descendants are constructed and T'Class itself. To make it clearer consider what would be the post-condition of Initialize: type T is ...; type S is new T ...; Initialize (X : in out T) ensure T'Operational (X) [*] or, maybe S'Operational (X) T'Class'Operational (X) S'Class'Operational (X) Now, the precondition of a dispatching call on T'Class is obviously: require T'Class'Is_Operational (X) Of course: T'Class'Operational (X) => T'Operational (X) T'Class'Operational (X) => S'Operational (X) >From this you can formally analyse if initialization is correct. > I believe that such dispatching may be quite useful in some designs, Yes it is. This is why there must be a hook at the end of construction of T'Class. The earliest point you can dispatch if when T'Class'Operational turns true. > just as re-dispatching is useful in some designs - IMO. No. This is a totally different case. > Moreover, I think this question of constructor/destructor control flow > is separate from the general question of preventing access to > uninitialized data. ? Initialization = construction. I don't see how are they different. ----------------- * T'Operational (X) is true when the object X can operate as an instance of T. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de