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

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!convex!constellation!iapa!ctrbdo
  3. From: ctrbdo@iapa.uucp%mailhost.ecn.uoknor.edu (bryan d oakley)
  4. Subject: ENTRY in main (was re: Jumping from nested subroutine to main directly)
  5. Message-ID: <By4xpo.FG@iapa.uucp%mailhost.ecn.uoknor.edu>
  6. Organization: FAA / Mike Monroney Aeronautical Center
  7. Date: Sun, 22 Nov 1992 20:46:34 GMT
  8. Lines: 44
  9.  
  10. >== Michael Page writes:
  11. > One way to almost do what he wants is to use an ENTRY statement at
  12. > the point he wants to return to in the main program.  However, I
  13. > suspect he wants something a bit more `automatic' than that, but I
  14. > don't think it exists in FORTRAN.  Does it exist in C, Pascal, ..?
  15.  
  16. Hmmm... I've been programming FORTRAN for 10ish years (if you count
  17. college) and NEVER thought to put an ENTRY in the main program,
  18. though at first glance it seems to be the only time I might consider
  19. using an ENTRY point (yes, I'm one of the people that frowns :-( on
  20. the use of ENTRY points).
  21.  
  22. Question: what does this do to the stack?  If you kept jumping back to
  23. the main routine everytime you had an error, and never 'returned' from
  24. the routine causing the error, wouldn't the stack just grow un-
  25. controllably?  Also, wouldn't this be considered recursion, since a
  26. routine subordinate to main (effectively) calls main?  I'm guessing
  27. the code would look like this (pardon the GOTOs :-):
  28.  
  29.     program example
  30.  
  31. c    top of main loop:
  32. 10        <get input...>
  33.         <process input ...>
  34.         <produce output ...>
  35.         if (.not. done) goto 10
  36.         goto 20
  37. c    end of main loop...
  38.  
  39.     ENTRY error
  40.     <process error condition>
  41.     if (.not. fatal) goto 10
  42.     goto 20
  43.  
  44. 20    end
  45.  
  46.  
  47. Does anybody do this in the real world?
  48.  
  49. -- 
  50. ----------------------------------------------------------------------
  51. Instrument Approach Procedures Automation              DOT/FAA/AMI-230
  52. ----------------------------------------------------------------------
  53. Bryan D. Oakley                    ctrbdo%iapa@mailhost.ecn.uoknor.edu
  54.