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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,183821e6c098051b X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: pragma Elaborate (Comp. Unit) question. Date: 1999/05/24 Message-ID: <3749F3B9.202F7A13@mitre.org>#1/1 X-Deja-AN: 481716102 Content-Transfer-Encoding: 7bit Organization: The MITRE Corporation X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-05-24T00:00:00+00:00 List-Id: > Should one ever *need* get an error message from a compiler that a > compilation unit needs to have a "pragma Elaborate" clause for another > unit? > > That is, if the compiler knows what the elaboration order needs to be > why can't it make the relavant deterministic change and proceed with a > warning? There is a very deep answer lurking here... For most programs, there exists an order of elaboration that can be discovered at compile time and will never cause Program_Error to be raised. Good compilers will try to choose a workable order but for some programs, finding that order is extremely hard in a computability sense. I once wrote an example of this where the "correct' order of elaboration depended on whether or not Fermat's Last Theorem was true. (Now that compilers can get that one right, I'll have to come up with a different example. ;-) But it gets worse. It is relatively trivial to write a program where data input from the keyboard at run-time determines whether or not a particular elaboration order works. (I've seen Comp Sci 101 students write such programs--without inteding to. ;-) It is a little trickier, but not much, to create a program where there are several possible elaboration orders at compile time, and for each one there are inputs that cause Program_Error, and others that don't. This is why pragma Elaborate, and in Ada 95, pragmas Elaborate_All and Elaborate_Body, are there. If the "correct" elaboration order for your program depends on Fermat's Last Theorem, you can tell the compiler what to do instead of relying on the compiler's built in theorem prover. Now back to the compile time error message. This message is trying to tell you that the compiler couldn't find a workable elaboration order, but maybe if you give it a hint... Of course, you often get the message when the elaboration order is already overconstrained and what you really need to do is to figure out how to remove some of the dependencies. The compiler is trying to be helpful and give you a clue as to where the problem is, but usually if you get that message, finding a workable order is hard. (See above.) Better is to restructure your program so that it is easy. This often involves spliting packages or moving some initialization code into the main program. Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...