home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4413 < prev    next >
Encoding:
Text File  |  1992-11-23  |  2.7 KB  |  56 lines

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