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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,af159f716ef5c24b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-20 01:59:11 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!EU.net!uunet!noc.near.net!inmet!dsd!bobduff From: bobduff@dsd.camb.inmet.com (Bob Duff) Subject: Re: pragma ELABORATE not allowed (Sun Ada) Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: Date: Tue, 18 Oct 1994 14:32:05 GMT Date: 1994-10-18T14:32:05+00:00 List-Id: In article , Ulf Stenhaug wrote: >package body configure is ... >end configure; > >with configure; >package rename_config is ... >end rename_config; ... >with rename_config; >with other_packages_which_also_use_configure; >program main is ^^^^^^^ You mean "procedure" or "package body" here. If it's a procedure (the main subprogram), then there should be no problem, since everything is elaborated before the main subprogram is called. So I assume this is really a package. Elaboration order is different on different implementations (within some constraints). So it's not surprising that the code happened to work on one compiler, and you got Program_Error on the other one. >Now to the real problem: We insert "pragma ELABORATE(rename_config)" >after the with-statement, but then the compiler refers to ARM >appendix B and complains that > "This pragma not allowed in this context." > >Why is it not allowed? What can we do?????? In Ada 83, you have to put all the pragmas Elaborate *after* all of the with_clauses and use_clauses. This restriction has been removed in Ada 9X. You really need to elaborate the body of Configure (not just Rename_Configure) before the body of package Main. This means you need to say pragma Elaborate(Configure). But in order to do that, you have to add "with Configure;". That's a real pain, because Main doesn't reference anything in Configure, and so shouldn't have to mention it in a with_clause. This is a flaw in the language design. This problem has also been solved in Ada 9X. In Ada 9X, you can say pragma Elaborate_All(Rename_Configure). This is just like pragma Elaborate, except that it automatically applies to everything the spec and body of Rename_Configure depends on. In Ada 9X, you should always use pragma Elaborate_All instead of Elaborate, except in certain rare circumstances involving mutually recursive packages, where Elaborate_All would cause a circularity. Ada 9X also has some other pragmas for controlling elaboration. Pragma Preelaborate (and pragma Pure) cause the package spec and body to be elaborated "first" (before non-preelaborated things). Pragma Elaborate_Body, means don't elaborate anything in between the spec and body of this package. All of these reduce your chances of getting Program_Error because you called something before it was elaborated. -- Bob Duff bobduff@inmet.com Oak Tree Software, Inc. Ada 9X Mapping/Revision Team (Intermetrics, Inc.)