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 X-Google-Thread: 103376,fd189a20f95495f3,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!feeder.erje.net!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Task components, the rationale Date: Wed, 13 Jul 2011 20:52:02 +0200 Organization: cbb software GmbH Message-ID: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 0gEzX7xNyz7xAL3b4pbLjA.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: g2news2.google.com comp.lang.ada:21168 Date: 2011-07-13T20:52:02+02:00 List-Id: OK, to avoid false impression that Ada was carelessly designed, it must be said that there was a valid reason why task components are broken this way. That is to prevent a much worse disaster when so-called Rosen's trick is used. Consider the pattern discussed earlier (the Rosen's trick): type T; task type Worker (Self : not null access T'Class); type T is new Ada.Finalization.Limited_Controlled with record My_Worker : Worker (T'Access); end record; overriding procedure Initialize (Object : in out T); procedure Foo (Object : in out T) is abstract; -- A primitive operation Now, if My_Worker started before completion of Initialize then this body task body Worker is begin Self.Foo; -- Boom! could call Foo of T or any of its derived type *before* Initialize, i.e. before the object's construction is done! That would be a much worse problem. There is no simple solution for this. To start with tasks must be inheritable from and their bodies must be primitive or class-wide operations, because aggregation (composition) + Rosen's trick is necessarily broken. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de