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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,901038687c38f61c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!news.cs.univ-paris8.fr!newsfeeds.phibee.net!news.clara.net!wagner.news.clara.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Idiom for a class and an object in Ada Date: 20 Oct 2004 20:37:42 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <41769aaf$0$91004$39cecf19@news.twtelecom.net> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1098301447 1456 62.49.19.209 (20 Oct 2004 19:44:07 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 20 Oct 2004 19:44:07 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: g2news1.google.com comp.lang.ada:5542 Date: 2004-10-20T20:37:42+01:00 List-Id: "Matthew Heaney" writes: > "Simon Wright" 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.