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.6 required=5.0 tests=BAYES_05,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!caip!lll-crg!lll-lcc!vecpyr!amd!pesnta!hplabs!hao!noao!terak!anasazi!steve From: steve@anasazi.UUCP (Steve Villee) Newsgroups: net.lang.ada Subject: Can CALENDAR.CLOCK be called during initialization? Message-ID: <247@anasazi.UUCP> Date: Thu, 8-May-86 00:09:40 EDT Article-I.D.: anasazi.247 Posted: Thu May 8 00:09:40 1986 Date-Received: Sun, 11-May-86 02:13:16 EDT Distribution: net Organization: Anasazi, Phoenix Az. List-Id: Is the following package declaration legal, and guarranteed not to raise PROGRAM_ERROR? with CALENDAR; pragma ELABORATE (CALENDAR); package FOO is MOMENT : CALENDAR.TIME := CALENDAR.CLOCK; end FOO; At first reading, section 10.5 of the LRM seems to suggest that it is safe to call any subprogram during initialization (that is, during the elaboration of a library package or its body), as long as you make sure the subprogram body has been elaborated using pragma ELABORATE. But after some thinking, I'm not sure this is true. It seems that a subprogram may or may not be "callable during initialization", and that making it so requires cooperation from the subprogram author, in general. Consider the following code: function A return INTEGER; function B return INTEGER; with B; pragma ELABORATE (B); package C is X : INTEGER := B; end C; with A; function B return INTEGER is begin return A; end B; function A return INTEGER is begin return 42; end A; During the elaboration of package C, function B is called, and an attempt is made to call function A. It seems quite possible that this invocation of function A might raise PROGRAM_ERROR if the body of A has not yet been elaborated. If function B were changed to include a "pragma ELABORATE (A);", the problem would be solved. Likewise, maybe CALENDAR.CLOCK calls some other subprogram and does not use pragma ELABORATE, so it may be unsafe to call CALENDAR.CLOCK during initialization. Or am I missing something? Is it a good general practice to use pragma ELABORATE on everything you call, so as to make your subprogram callable during initialization? --- Steve Villee (ihnp4!terak!anasazi!steve) International Anasazi, Inc. 7500 North Dreamy Draw Drive, Suite 120 Phoenix, Arizona 85020 (602) 870-3330