comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Mutual Recursion (was Re: SOLVED! Decoupled Mutual Recursion Challenger)
Date: 28 Oct 94 09:03:47
Date: 1994-10-28T09:03:47+00:00	[thread overview]
Message-ID: <EACHUS.94Oct28090347@spectre.mitre.org> (raw)
In-Reply-To: rob@brewster.demon.co.uk's message of Thu, 27 Oct 1994 04:25:51 +0000


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...



  reply	other threads:[~1994-10-28  9:03 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-12 22:49 SOLVED! Decoupled Mutual Recursion Challenger John Volan
1994-10-17 15:48 ` John Volan
1994-10-17 17:55   ` Bob Duff
1994-10-17 20:52     ` John Volan
1994-10-17 22:10       ` Bob Duff
1994-10-18 22:17         ` John Volan
1994-10-19  1:01           ` Bob Duff
1994-10-19  4:45             ` Jay Martin
1994-10-19 14:38               ` Mark A Biggar
     [not found]                 ` <38fi4r$l81@oahu.cs.ucla.edu>
1994-10-24 11:49                   ` Mutual Recursion Challenge Robert I. Eachus
1994-10-24 20:32                     ` John Volan
1994-10-26 11:42                       ` Generic association example (was Re: Mutual Recursion Challenge) Robert I. Eachus
1994-10-26 23:21                         ` John Volan
1994-10-27 10:53                           ` Robert I. Eachus
1994-10-31 17:34                             ` John Volan
1994-10-27 14:37                           ` Mark A Biggar
1994-10-24 17:42                   ` SOLVED! Decoupled Mutual Recursion Challenger John Volan
1994-10-24 22:37                     ` Jay Martin
1994-10-25  5:47                       ` Matt Kennel
1994-10-25 10:04                         ` David Emery
1994-10-25 16:43                         ` John Volan
1994-10-27  4:25                           ` Rob Heyes
1994-10-28  9:03                             ` Robert I. Eachus [this message]
1994-10-28 15:04                             ` Robb Nebbe
1994-10-25 15:54                       ` John Volan
1994-10-26  1:24                         ` Bob Duff
1994-10-28  4:28                         ` Jay Martin
1994-10-28 10:52                           ` Robert I. Eachus
1994-10-28 18:46                             ` Jay Martin
1994-11-02 14:56                               ` Robert I. Eachus
1994-10-29  0:38                           ` Bob Duff
1994-10-29  7:26                             ` Jay Martin
1994-10-29 11:59                             ` Richard Kenner
1994-10-31 13:17                               ` Robert Dewar
1994-10-31 14:13                               ` gcc distribution (was: SOLVED! Decoupled Mutual Recursion Challenger) Norman H. Cohen
1994-11-02 14:14                                 ` Richard Kenner
1994-11-04 23:56                                   ` Michael Feldman
1994-10-31 18:44                           ` SOLVED! Decoupled Mutual Recursion Challenger John Volan
1994-10-20 11:25               ` Robb Nebbe
1994-10-20 19:19                 ` John Volan
1994-10-26  0:07                 ` Mark S. Hathaway
1994-10-26 18:48                 ` gamache
1994-10-27  2:15                   ` John Volan
     [not found]           ` <CxwGJF.FwB@ois.com>
1994-10-19 16:35             ` John Volan
1994-10-17 22:54   ` Cyrille Comar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox