From: Simon Wright <simon@pushface.org>
Subject: Re: Idiom for a class and an object in Ada
Date: 20 Oct 2004 20:37:42 +0100
Date: 2004-10-20T20:37:42+01:00 [thread overview]
Message-ID: <x7voeixb2pl.fsf@smaug.pushface.org> (raw)
In-Reply-To: 41769aaf$0$91004$39cecf19@news.twtelecom.net
"Matthew Heaney" <mheaney@on2.com> writes:
> "Simon Wright" <simon@pushface.org> wrote in message
> news:x7v4qkqrlr1.fsf@smaug.pushface.org...
> >
> > package body ADC is
> >
> > task type T is ...
> > type T_P is access T;
> > Converter_1 : T_P;
> >
> > begin
> >
> > Converter_1 := new T (...);
> >
> > end ADC;
>
> This doesn't buy you anything. The rule is that the "task object"
> elaborates in linear order (the same as for any other declaration), but then
> the "task" itself "activates" when the begin statement is reached.
>
> We can write your example as:
>
> package body ADC is
> task type T;
>
> O : T; -- this is the "task object"
>
> task body T is ... end;
>
> end;
>
> No explicit allocation is necessary. Task object O elaborates in the normal
> way, and its associated task activates at the completion of elaboration of
> the package body.
And this is exactly why you end up with elaboration order problems!
package A is
procedure P;
end A;
with B;
package body A is
procedure P is
begin
null;
end P;
end A;
package B is
procedure Q;
end B;
with A;
package body B is
task type T is
entry Start;
end T;
O : T;
task body T is
begin
accept Start;
A.P;
end T;
procedure Q is
begin
null;
end Q;
end B;
with A;
procedure M is
begin
null;
end M;
smaug.pushface.org[7]$ gnatmake m
gcc -c m.adb
gcc -c a.adb
gcc -c b.adb
gnatbind -x m.ali
error: elaboration circularity detected
info: "b (body)" must be elaborated before "b (body)"
info: reason: implicit Elaborate_All in unit "b (body)"
info: recompile "b (body)" with -gnatwl for full details
info: "b (body)"
info: must be elaborated along with its spec:
info: "b (spec)"
info: which is withed by:
info: "a (body)"
info: which must be elaborated along with its spec:
info: "a (spec)"
info: which is withed by:
info: "b (body)"
gnatmake: *** bind failed.
--
Simon Wright 100% Ada, no bugs.
next prev parent reply other threads:[~2004-10-20 19:37 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-18 11:47 Idiom for a class and an object in Ada Marin David Condic
2004-10-18 12:14 ` Martin Krischik
2004-10-18 19:40 ` Matthew Heaney
2004-10-19 12:59 ` Marin David Condic
2004-10-19 14:46 ` Martin Dowie
2004-10-19 15:55 ` Matthew Heaney
2004-10-19 18:31 ` Martin Dowie
2004-10-19 15:52 ` Matthew Heaney
2004-10-18 12:26 ` Marius Amado Alves
2004-10-19 2:09 ` Jeffrey Carter
2004-10-19 3:28 ` Matthew Heaney
2004-10-19 12:53 ` Marin David Condic
2004-10-19 14:44 ` Matthew Heaney
2004-10-19 15:01 ` Dmitry A. Kazakov
2004-10-19 15:40 ` Matthew Heaney
2004-10-20 7:58 ` Dmitry A. Kazakov
2004-10-20 12:31 ` Marin David Condic
2004-10-20 13:53 ` Dmitry A. Kazakov
2004-10-20 15:23 ` Matthew Heaney
2004-10-21 12:24 ` Marin David Condic
2004-10-21 17:15 ` Matthew Heaney
2004-10-20 5:39 ` Simon Wright
2004-10-20 7:24 ` Matthew Heaney
2004-10-20 8:39 ` Dmitry A. Kazakov
2004-10-21 1:36 ` Jeffrey Carter
2004-10-21 1:46 ` Matthew Heaney
2004-10-21 7:51 ` Dmitry A. Kazakov
2004-10-21 12:45 ` Matthew Heaney
2004-10-21 14:11 ` Dmitry A. Kazakov
2004-10-22 1:04 ` Jeffrey Carter
2004-10-22 1:36 ` Matthew Heaney
2004-10-21 19:31 ` Kevin Cline
2004-10-21 22:02 ` Matthew Heaney
2004-10-22 0:10 ` Matthew Heaney
2004-10-21 8:25 ` Martin Dowie
2004-10-20 17:04 ` Matthew Heaney
2004-10-20 19:37 ` Simon Wright [this message]
2004-10-20 20:04 ` Matthew Heaney
2004-10-22 5:37 ` Simon Wright
2004-10-20 1:10 ` Jeffrey Carter
2004-10-20 7:04 ` Matthew Heaney
2004-10-20 12:42 ` Marin David Condic
2004-10-20 12:55 ` Matthew Heaney
2004-10-20 15:27 ` Matthew Heaney
2004-10-21 1:36 ` Matthew Heaney
2004-10-19 12:38 ` Marin David Condic
2004-10-18 16:59 ` Matthew Heaney
2004-10-18 18:02 ` Martin Dowie
2004-10-19 13:06 ` Marin David Condic
2004-10-19 14:51 ` Martin Dowie
2004-10-20 16:20 ` Michael Paus
2004-10-20 17:15 ` Matthew Heaney
2004-10-20 17:55 ` Michael Paus
2004-10-21 12:33 ` Marin David Condic
-- strict thread matches above, loose matches on Subject: below --
2004-10-21 13:59 Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox