Re: Unchecked_Conversion and task pointer.



"Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> wrote in message
news:1xuh1gs97pwwg$.1v4w9ruw1n2x$.dlg@xxxxxxxxxxxxx
....
> Task types are not tagged in Ada (alas).

Task types that inherit from an interface are tagged in Ada 200Y.

> So if you are trying to have a
> kind of task types hierarchy you should use mix-in.

No, you should definitely use an interface. Other than that you may not be
able to find a compiler that supports them yet.

Note that you can't derive from a task type; those have to be leaves in the
hierarchy.


package Persons is
type Root_Person is interface;
procedure Who_an_I (Person : in Root_Person);
type Access_Person is access Root_Person'Class;
end Persons;

task type Cain and Persons.Root_Person is
entry Who_Are_You;
end Cain;

task type Abel and Persons.Root_Person is
entry Who_Are_You;
end Abel;

-- The bodies of the tasks remain the same.

Someone : Access_Person := Abel'Access;

Someone.Who_am_I; -- Dispatch to the appropriate entry.
Who_am_I (Someone.all); -- The same call in "normal" notation.


Randy;



.