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,93fa00d728cc528e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-28 08:21:36 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!EU.net!uunet!world!blanket.mitre.org!linus.mitre.org!linus!mbunix!eachus From: eachus@spectre.mitre.org (Robert I. Eachus) Newsgroups: comp.lang.ada Subject: Mutual Recursion (was Re: SOLVED! Decoupled Mutual Recursion Challenger) Followup-To: comp.lang.ada Date: 28 Oct 94 09:03:47 Organization: The Mitre Corp., Bedford, MA. Message-ID: References: <38hcv3$j85@baleen.cs.ucla.edu> <38i65r$li2@network.ucsd.edu> <1994Oct25.164314.28453@swlvx2.msd.ray.com> <783257151snx@brewster.demon.co.uk> NNTP-Posting-Host: spectre.mitre.org In-reply-to: rob@brewster.demon.co.uk's message of Thu, 27 Oct 1994 04:25:51 +0000 Date: 1994-10-28T09:03:47+00:00 List-Id: In article <783257151snx@brewster.demon.co.uk> rob@brewster.demon.co.uk (Rob Heyes) writes: > What happens with mutually recursive procedures in Ada then? The > above statement would seem to preclude the possibility if Ada is > so consistent. If I've got hold of the wrong end of the stick > then please tell me. Mutually recursive procedures are usually not a problem, because, in general all elaboration occurs before procedures get called. But: Elaboration is a property of declarations, and in any language I hope it is impossible to call a procedure before it is declared. Ada, however, also requires that the body of a subprogram be declared before the procedure can be called. This allows time for eveything visible to the body of the subprogram to be elaborated before it is referenced. The case most people run into is when they try to use a function defined in a declarative part to initialize a variable declared in the same declarative part. It doesn't work (unless the function is a generic instantiation) due to the circular visibility problem: function F return Integer; X: Integer := F; ... function F return Integer is begin return X; end F; It is legal to write this, but there is no possible valid elaboration order, so you will get PROGRAM_ERROR at run-time. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...