comp.lang.ada
 help / color / mirror / Atom feed
* Task components, the rationale
@ 2011-07-13 18:52 Dmitry A. Kazakov
  2011-07-13 20:58 ` Maciej Sobczak
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2011-07-13 18:52 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-22 23:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 18:52 Task components, the rationale Dmitry A. Kazakov
2011-07-13 20:58 ` Maciej Sobczak
2011-07-14  8:52   ` Georg Bauhaus
2011-07-14 18:15     ` Maciej Sobczak
2011-07-22 23:28       ` Randy Brukardt
2011-07-14  9:23   ` Dmitry A. Kazakov

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