home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!hal!map
- From: map@hal.maths.monash.edu.au (Michael Page)
- Subject: Re: ENTRY in main (was re: Jumping from nested subroutine)
- Message-ID: <1992Nov23.114807.4734@monu6.cc.monash.edu.au>
- Sender: news@monu6.cc.monash.edu.au (Usenet system)
- Organization: Mathematics Department, Monash University, Australia.
- References: <By4xpo.FG@iapa.uucp%mailhost.ecn.uoknor.edu>
- Date: Mon, 23 Nov 1992 11:48:07 GMT
- Lines: 44
-
- (bryan d oakley) writes:
- >>== Michael Page writes:
- >> One way to almost do what he wants is to use an ENTRY statement at
- >> the point he wants to return to in the main program. However, I
- >> suspect he wants something a bit more `automatic' than that, but I
- >> don't think it exists in FORTRAN. Does it exist in C, Pascal, ..?
- >
- > Hmmm... I've been programming FORTRAN for 10ish years (if you count
- > college) and NEVER thought to put an ENTRY in the main program,
- > though at first glance it seems to be the only time I might consider
- > using an ENTRY point (yes, I'm one of the people that frowns :-( on
- > the use of ENTRY points).
- >
- >Question: what does this do to the stack? If you kept jumping back to
- >the main routine everytime you had an error, and never 'returned' from
- >the routine causing the error, wouldn't the stack just grow un-
- >controllably?
-
- After I posted, I had this vague recollection that ENTRY could only be
- used in subroutines. But even if this were true the original author's
- requirement could be simulated by having an entry statement at the end
- of each "level one" subroutine, say called "ENTRY exit<subname>". I
- must confess that the only thing I have ever used ENTRY statements for
- is error handling. (My fatal error messages are all printed out from
- a single subroutine with multiple entry points, to avoid cluttering the
- code where the error occurs.)
-
- ENTRY statements are a form of global GOTO statement and, much as I
- detest and discourage GOTOs, they do have an occasional application,
- in particular for error handling. I'm not encouraging their use but
- they do seem to have a place in the language.
-
- > Also, wouldn't this be considered recursion, since a routine subordinate
- > to main (effectively) calls main?
-
- Recursion is already possible (and legal?) in standard FORTRAN by simply
- having two subroutines which are different only in name that call each
- other. I have no idea what this does to the stack, though.
-
- --
- +------------------------------------------------------------------------------+
- Michael Page, Maths Dept, Monash University, Clayton, Victoria, AUSTRALIA 3168
- email: map@hal.maths.monash.edu.au phone: +61 3 565 4486 FAX: +61 3 565 4403
- +------------------------------------------------------------------------------+
-